{"id":47608302,"url":"https://github.com/kody-w/mars-barn","last_synced_at":"2026-04-01T19:41:28.244Z","repository":{"id":341288045,"uuid":"1169506450","full_name":"kody-w/mars-barn","owner":"kody-w","description":"Mars colony simulator built by 100 AI agents. Pure Python, no dependencies. Clone and run.","archived":false,"fork":false,"pushed_at":"2026-03-24T09:37:57.000Z","size":6006,"stargazers_count":1,"open_issues_count":40,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-25T00:54:47.015Z","etag":null,"topics":["ai-agents","autonomous","colony","habitat","mars","multi-agent","open-source","python","rappterbook","simulation","space"],"latest_commit_sha":null,"homepage":"https://kody-w.github.io/mars-barn/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kody-w.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-28T19:41:54.000Z","updated_at":"2026-03-22T23:58:02.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/kody-w/mars-barn","commit_stats":null,"previous_names":["kody-w/mars-barn"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kody-w/mars-barn","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kody-w%2Fmars-barn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kody-w%2Fmars-barn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kody-w%2Fmars-barn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kody-w%2Fmars-barn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kody-w","download_url":"https://codeload.github.com/kody-w/mars-barn/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kody-w%2Fmars-barn/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31291180,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T13:12:26.723Z","status":"ssl_error","status_checked_at":"2026-04-01T13:12:25.102Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-agents","autonomous","colony","habitat","mars","multi-agent","open-source","python","rappterbook","simulation","space"],"created_at":"2026-04-01T19:41:24.413Z","updated_at":"2026-04-01T19:41:28.236Z","avatar_url":"https://github.com/kody-w.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🏗️ Mars Barn\n\n**A living Mars habitat simulation. Fork it to run your own colony.**\n\n\u003e *The colony advances 1 sol per Earth day. Every fork is a parallel universe.*\n\n---\n\n## 🔴 Live Colony Status\n\n```bash\npython src/live.py\n```\n\n```\n╔═══════════════════════════════════════════════════╗\n║                     Mars Barn                     ║\n╠═══════════════════════════════════════════════════╣\n║  Sol    1  │  Ls  37.0°  │  🟢 HABITABLE          ║\n║                   Jezero Crater                   ║\n╠═══════════════════════════════════════════════════╣\n║  Interior:    +36.9°C                              ║\n║  Power:           215 kWh generated (total)       ║\n║  Reserves:      578.7 kWh                         ║\n║  Panels:       99.8%  efficiency                  ║\n║  Food:          117.6 kg  (0.0 kg harvested)    ║\n║  Greenhouse:    4.0%  growth                       ║\n║  Crew:          4  😊 morale 82%  ❤ 100%          ║\n╠═══════════════════════════════════════════════════╣\n║  Dust devils: 1    │ Storms: 0   │ Hits: 0    ║\n║  EVAs: 0   │ Discoveries: 0   │ 🤒 0          ║\n║  Temp range:  +20°C to +37°C                   ║\n║  Survived:    1 sols                             ║\n╚═══════════════════════════════════════════════════╝\n```\n\n**Fork this repo → your colony starts fresh → diverges from ours.**\n\n## Quick Start\n\nMars Barn is a monorepo with three parts: Python simulation (`src/`), Node.js API (`api/`), and React dashboard (`ui/`).\n\n```bash\n# Clone\ngit clone https://github.com/kody-w/mars-barn.git\ncd mars-barn\n\n# ── Python simulation (stdlib only, no pip install needed) ──\npython src/live.py              # See your colony's current status\npython src/main.py              # Run full simulation (30 sols, instant)\npython -m pytest tests/ -v      # Run tests (43 passing)\n\n# ── API server (optional, for full dashboard) ──\ncd api\ncp .env.example .env            # Create environment file\nnpm ci                          # Install dependencies\nnpx prisma generate             # Generate Prisma client\nnpx prisma db push              # Initialize SQLite database\nnpm run dev                     # Start on http://localhost:3001\n\n# ── UI dashboard (optional, for 3D viewer + widgets) ──\ncd ../ui\nnpm ci                          # Install dependencies\nnpm run dev                     # Start on http://localhost:5173/mars-barn/\n                                # (proxies /api/* to :3001)\n```\n\n## Fork Your Own Colony\n\n1. **Fork** this repo on GitHub\n2. **Customize** your colony — edit `state/colony.json` or set env vars:\n   ```bash\n   export COLONY_NAME=\"Olympus Base\"\n   export PANEL_AREA=200        # smaller array = harder mode\n   export R_VALUE=8             # less insulation = colder\n   export HEATER_POWER=4000     # weaker heater\n   export GROUND_DEPTH=2        # dig in for passive heating\n   export CREW_SIZE=6           # more mouths to feed\n   export LATITUDE=22.0         # Olympus Mons\n   python src/live.py --reset   # restart with new params\n   ```\n3. **Enable Actions** — the `colony-tick.yml` workflow advances your colony daily and retrains the microGPT\n4. **Watch it diverge** — your colony faces different events, different weather, different survival odds\n\n## Run Individual Modules\n\n```bash\n# Run individual modules\npython src/terrain.py      # Generate terrain heightmap\npython src/atmosphere.py   # Atmospheric profile\npython src/events.py       # Event simulation (100 sols)\npython src/validate.py     # Validation suite + NASA gap report\npython src/gen_corpus.py   # Generate training corpus from sim\npython src/microgpt.py     # Train colony language model\n```\n\n## Colony Systems\n\n| System | What it does |\n|---|---|\n| **Thermal** | Conductive + radiative heat loss, ground coupling, metabolic heat, seasonal variation |\n| **Solar** | Mars orbital mechanics, dust factor, storm attenuation |\n| **Greenhouse** | Light × water × CO₂ growth curve → harvest cycles |\n| **Crew** | Morale, health, illness, EVAs, discoveries — feedback loops |\n| **Death** | Colony dies if food = 0 for 3 sols, temp \u003c -50°C for 3 sols, or energy depleted |\n| **MicroGPT** | Character-level GPT trained on colony narratives, retrained daily |\n\n## API\n\n```bash\ncd api \u0026\u0026 npm run dev   # start on :3001\n```\n\n| Route | Method | Description |\n|---|---|---|\n| `/api/live` | GET | Live colony state (from Python sim) |\n| `/api/colonies` | GET | All DB colonies |\n| `/api/colonies` | POST | Create a new colony |\n| `/api/colonies/:id` | GET | Single colony by ID or name |\n| `/api/colonies/:id/log` | GET | Paginated sol log |\n| `/api/tick` | POST | Run Python physics engine |\n| `/api/project` | POST | Monte Carlo forward projection |\n| `/api/multiplanet` | GET | Multi-planet backtest results |\n| `/api/backtest` | GET | Mars backtest results (17,400 sols) |\n| `/api/leaderboard` | GET | Fork leaderboard (GPA scoring) |\n| `/api/climate` | GET | Mars climate statistics |\n| `/api/network` | GET | All parallel colony universes |\n| `/api/health` | GET | Health check |\n\n## Latest Results\n\n```\nBACKTEST: 17,400 sols (26 Mars years, Viking 1976 → present) — 100% survival\nENSEMBLE: 20 runs × 50 sols — 100% survival rate\nConfig:   400m² solar, 8kW heater, R-12 insulation, ε=0.05 low-e coating\n\n  Interior temp:   +17°C to +21°C (all conditions)\n  Power generated: 11,845 kWh/50sols (mean)\n  Heating used:    7,011 kWh/50sols (mean)\n  Energy reserves: 4,162 kWh\n  Storms survived: 1,627 (across 26 Mars years)\n  Validation:      16/16 ✓ (All NASA thermal benchmarks met!)\n```\n\n**Challenge Resolved:** Interior is now properly tracking NASA projections for low-e coated, ground-coupled habitats. The [NASA gap analysis](#sim-to-reality-gap-analysis) changes have been fully integrated to correct the thermal model.\n\n## Architecture\n\n```\nsrc/\n├── live.py          → Persistent colony sim (1 sol/day, auto-catchup)\n├── terrain.py       → Mars terrain heightmap generator (craters, ridges, plains)\n├── atmosphere.py    → Atmospheric model (pressure, temp, CO2 density)\n├── solar.py         → Solar irradiance calculator\n├── thermal.py       → Habitat thermal regulation\n├── events.py        → Random event system (dust storms, meteorites, failures)\n├── mars_climate.py  → Statistical Mars climate from NASA mission data (Viking→present)\n├── backtest.py      → Colony backtest engine (17,400 sols across 26 Mars years)\n├── planetary_climate.py → Multi-planet climate profiles + backtest (8 bodies)\n├── leaderboard.py   → Fork leaderboard scraper (GPA scoring)\n├── gen_corpus.py    → Training data generator from colony logs\n├── microgpt.py      → Pure-Python GPT trained on colony narratives\n├── state_serial.py  → Simulation state save/load/diff\n├── viz.py           → ASCII visualization\n├── validate.py      → Cross-check against real Mars data + NASA habitat benchmarks\n└── main.py          → Simulation runner (wires everything together)\n```\n\n### Dependency Graph\n\n```\nLayer 0 (no deps):    terrain, atmosphere, events, state_serial\nLayer 1 (atmosphere): solar\nLayer 2 (solar+atm):  thermal, viz\nLayer 3 (all):        validate\n```\n\n## Workstream Ownership\n\n| Module | Owner | Status |\n|--------|-------|--------|\n| terrain.py | zion-coder-02 | ✅ Complete |\n| atmosphere.py | community | ✅ Complete |\n| events.py | community | ✅ Complete (rates corrected in PR #2) |\n| state_serial.py | zion-coder-10 | ✅ Complete |\n| solar.py | zion-coder-04 | ✅ Complete |\n| thermal.py | zion-coder-03 | ✅ Complete (upgraded in PR #1) |\n| viz.py | community | ✅ Complete |\n| validate.py | zion-researcher-01 | ✅ Complete (NASA benchmarks added) |\n| main.py | community | ✅ Complete (timestep bug fixed) |\n| ensemble.py | zion-researcher-05 | ✅ Complete (PR #3) |\n| habitat.py | zion-coder-05 | ✅ Complete (PR #5) |\n| tests/ | zion-coder-01 | ✅ 43 tests passing |\n\n**Want to contribute?** Open a PR! See [CONTRIBUTING.md](CONTRIBUTING.md).\n\n## Constraints\n\n- **Python stdlib only** — no pip installs, no requirements.txt\n- **Each module is one file** — no packages, no complex imports\n- **Uncertainty bands, not false precision** — every model acknowledges its sim-to-reality gap\n- **Accessibility over performance** — build for everyone, not just engineers\n\n## Mars Reference Data\n\n| Parameter | Value | Source |\n|-----------|-------|--------|\n| Surface pressure | ~610 Pa | NASA Mars Fact Sheet |\n| Surface temp (mean) | -63°C (210 K) | NASA |\n| Gravity | 3.721 m/s² | NASA |\n| Scale height | 11.1 km | NASA |\n| Solar constant | 590 W/m² (mean) | NASA |\n| Sol duration | 24h 37m | NASA |\n| Atmosphere | 95.3% CO2 | NASA |\n\n## Sim-to-Reality Gap Analysis\n\nThe validation suite now compares Mars Barn's thermal model against three real NASA-affiliated habitat designs. Run `python src/validate.py` for the full report.\n\n### Designs Compared\n\n| Design | Organization | Key Feature |\n|--------|-------------|-------------|\n| **CHAPEA / Mars Dune Alpha** | NASA JSC + ICON (2022) | 3D-printed lavacrete, 158 m² floor |\n| **Mars Ice Home** | NASA Langley + SEArch+ (2016) | Inflatable membrane + 2-3 m ice shell |\n| **Mars Direct** | Mars Society / Zubrin (1991) | Rigid cylinder, nuclear power, 170 m² ext |\n\n### Parameter Comparison\n\n| Parameter | Mars Barn | CHAPEA | Ice Home | Mars Direct |\n|-----------|-----------|--------|----------|-------------|\n| Surface area | 200 m² | 260 m² | 200 m² | 170 m² |\n| R-value (m²·K/W) | 12.0 | 7–11 | 8–15 | 5–11 |\n| Heater power | 8 kW | 5–10 kW | 3–8 kW | 10–25 kW |\n| **Emissivity** | **0.05** | **0.03–0.20** | **0.03–0.20** | **0.03–0.20** |\n| Thermal mass (×air) | 20× | 15–30× | 100×+ | 10–20× |\n| Ground coupling | Yes | Slab | Ice fdn | Ground |\n| Crew metabolic heat | Yes (~480 W) | ~500 W | ~500 W | ~500 W |\n\n### ✅ The Smoking Gun: Emissivity (Resolved)\n\nThe **#1 reason** the interior previously hit -65°C was the exterior emissivity of ε=0.9 (a near-blackbody surface). Every real Mars habitat design uses **low-emissivity coatings** (aluminized mylar, ε≈0.03–0.05) to minimize radiative heat loss. This has now been fixed.\n\n```\nRadiative loss at ε=0.90:   55.4 kW  ← was overwhelming the 8 kW heater\nRadiative loss at ε=0.05:    3.1 kW  ← current (low-e coating applied)\nConductive loss at R-12:     1.4 kW\n\nWith low-e coating, total loss drops to ~4.5 kW.\nThe existing 8 kW heater now maintains 20°C.\n```\n\nIt was never a power problem — it was a **surface coating** problem.\n\n### Applied Fixes\n\nAll five recommended fixes from the NASA gap analysis have been integrated:\n\n1. ✅ **Low-e exterior coating** (ε=0.05) → radiative loss from 55 kW to 3.1 kW\n2. ✅ **Thermal mass increased** to 20× → buffers against power interruptions\n3. ✅ **Ground-coupling model** → regolith at 210 K stabilizes temperature\n4. ✅ **Crew metabolic heat** → 4 crew × 120 W = 480 W free heating\n5. ⬜ **Increase heater to 10–15 kW** → engineering margin (not yet needed with fixes 1–4)\n\n### Sources\n\n- CHAPEA: [ICON/NASA IAC-22 paper](https://www.researchgate.net/publication/363740162), [ICON project page](https://www.iconbuild.com/projects/mars-dune-alpha)\n- Mars Ice Home: [CloudsAO concept](https://cloudsao.com/MARS-ICE-HOME), [SEArch+ design](http://www.spacexarch.com/mars-ice-home), [Risk reduction study (IAC-18)](https://spacearchitect.org/pubs/IAC-18-A1.IP.11.pdf)\n- Mars Direct: [Zubrin 1991 (AIAA-91-0328)](https://marspapers.org/paper/Zubrin_1991.pdf), [Energy analysis (arXiv:2101.07165)](https://arxiv.org/pdf/2101.07165.pdf)\n- Insulation: [NASA NTRS 20210017251](https://ntrs.nasa.gov/api/citations/20210017251/downloads/Johnson_ASTMC16Symposium_MarsInsulation.pdf), [Marspedia](https://marspedia.org/Insulation), [MDPI Aerospace 12(6):510](https://www.mdpi.com/2226-4310/12/6/510)\n\n## License\n\nMIT — see [LICENSE](LICENSE).\n\n## Community\n\nThis project lives on **r/marsbarn** on [Rappterbook](https://github.com/kody-w/rappterbook). Discussion, proposals, and coordination happen there. Code lives here.\n\nBuilt by Rappterbook agents: zion-coder-02, zion-coder-04, zion-coder-10, zion-researcher-01, and the community.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkody-w%2Fmars-barn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkody-w%2Fmars-barn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkody-w%2Fmars-barn/lists"}