magicciv/.project/objectives/p3-26-complete-headless-simulator.md
Natalie 0752a51fb6 docs(@projects/@magic-civilization): p3-26 — B1+B2 done, B8 events 6/12 (parallel batch integrated)
Parallel migration batch (2 worktree agents) fully integrated + test-green:
- B1 happiness/golden-age + B2 healing → mc-turn (d5729d67c, 271/0).
- B8 events 6/12 → seismic/impact/tsunami added (afa7613fd, mc-climate 61/0).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 15:47:21 -04:00

7 KiB

id title priority scope owner status updated_at
p3-26 Complete the headless simulator — close the live-vs-headless system gaps (loop done-criterion) p3 game1 warcouncil partial 2026-06-26

Summary

Owner directive (2026-06-26): the /loop "continue until Game-1 done" is not finished until the SIMULATOR is complete — the headless Rust sim (mc-turn::TurnProcessor, driven via GdPlayerApi/magic_civ_*) must play a full self-play game with ALL systems, not the reduced subset shipped so far. See project_loop_done_means_simulator_complete.

The headless step() (processor.rs:392+) currently runs: trade (p3-25), economy, city_production (single queue), culture+border expansion, tech/science, fauna encounters, combat/siege, diplomacy. Verified live via magic_civ_view (e.g. border expansion fired turn 0→1: owned_tiles [[1,6]]→[[1,6],[0,6]]).

Gaps (each verified absent from the headless turn):

Acceptance (sequenced; each gap closed in bounded, cargo+e2e-verified increments)

  • [~] Gap 1 — Climate / environment runtime. STARTED 2026-06-26: mc-turn::process_climate_phase now ticks ClimatePhysics::process_step + weather::derive_events + climate_effects::apply (tile effects + unit HP loss, mirroring climate_effects.gd: hp=max(0,hp-loss)) each round on state.grid. Tests: climate_phase_ticks_grid_deterministically, apply_climate_effects_fans_hp_loss_onto_units; mc-turn 337/0. Remaining: marine_harvest (ocean_dead_fraction feeding climate). ORIG SPEC: Port the live per-turn chain marine_harvest → climate(ecology+climate physics) → weather → climate_effects (turn_processor.gd::_process_climate) into a mc-turn climate phase. The PHYSICS is already Rust (mc-climate: physics.process_step, climate_effects::apply, atmosphere, ecology); only the per-turn ORCHESTRATION is GDScript-only. Wire it onto state.grid in step(). Effects: weather events + unit HP damage + tile climate shifts in the headless sim.
  • [~] Gap 2 — Natural / "apocalyptic" events (M3 milestone). STARTED 2026-06-26: ported the deterministic core to mc-climate::events (hash_noise/roll_severity/category_fires), verified to match the live GDScript game bit-for-bit (hash_noise(10,0,1000)=0.67791910066535; the TS web guide's Math.sin diverges on large args — separate concern). NB: .messy is gone; the source is the live ecological_events.gd + ecological_event_handlers_a/b.gd + 12-category JSON in public/resources/events/. Progress 2026-06-26: mc-climate::events = deterministic core (GDScript-verified) + config model/loader + dispatch (process_events) + WILDFIRE & DROUGHT categories (effect + dispatch) + wired into mc-turn climate phase + GdPlayerApi.set_events_config_json FFI + headless-harness loading (DataLoader.get_ecological_events). ~10 events tests; mc-turn 338/0; dylib rebuilt (FFI present) + boot GUT 750/0. Live categories (3): wildfire, drought, volcanic — map cleanly to existing grid fields (biome/moisture/quality/sulfate_aerosol). Remaining categories need more than the pattern: seismic/impact/tsunami (elevation/crater/coastal terrain ops — geological, partially portable); solar/glacial (need climate-physics to consume new solar_forcing/glacial_forcing fields); plague/pandemic/marine (need fauna/marine subsystem integration — fish_stock/reef, fauna population death); magical deferred to Game-3 + surfacing fired events in the turn result/view + era-based max_tier cap. ORIG: Port the .messy ecological_events.gd (992 lines) → Rust, split per the milestone plan (.project/tasks/milestones/m3-natural-events/): geological (volcano/impact/seismic/ tsunami), ecological (wildfire/drought/plague/pandemic), marine, weather (already in gap 1), global (solar/glacial). Deterministic from seed per EVENT_FREQUENCY_SPEC.md; triggers from climate (gap 1), damage targets in biology (fauna/ecology). Wire into the turn. (Magic category excluded — M4.)
  • Gap 3 — Equipment / crafting. mc-city/recipes.rs + enqueue_item exist but there is no headless Craft/Equip PlayerAction and crafting isn't in the bench turn. Add the action(s) + dispatch + wire recipe resolution (gating resources, quality) into the headless production/turn so equipment is craftable in self-play.
  • Gap 4 — Per-building build queues. Bench CityState has a single queue; per-building queues live in the full mc_city::City (live game). This is the dual city-model split (p3-25 ... step 6 / city_slot.rs). Either give CityState per-building queues or unify the models so the headless turn simulates them.

Notes

Created 2026-06-26. This is a large multi-milestone mandate — closing it means porting the remaining GDScript-orchestrated simulation into Rust/mc-turn (full Rail-1). Sequenced climate → events (depends on climate triggers) → equipment → per-building queues. Each gap lands in bounded increments with cargo + the headless e2e (process_* tests + magic_civ_view) green. Reference impls in @magic-civilization.messy/ per atomic-porting rules. Related: p3-25 ... (the dual city model underlies gaps 1+4).

Full migration backlog (verified 2026-06-26 — live turn pipeline vs headless mc-turn step)

Diffed turn_processor.gd/turn_manager.gd (live per-turn calls) against mc-turn::step (grep confirmed 0 hits for each "missing" subsystem). Done in headless: trade, economy, city-production+growth, culture+border, tech/science, fauna encounters, PvP/siege/lair combat, climate physics+weather+effects, 3 event categories.

Backlog (live-only → migrate into mc-turn):

  • B1 Happiness + Golden Age (7993ba7ca — happiness_phase.rs, wired post-economy-loop) — mc-happiness exists; tick per-turn (golden-age meter, anarchy).
  • B2 Unit + city healing (7993ba7ca — healing.rs, wired post-climate) — HP regen (in-territory / fortified / city heal).
  • B3 Improvements build tick_process_improvements (build progress, not just yields).
  • B4 Government/civics per-turnmc-civics; (disabled in live too — stub).
  • B5 Loot decaymc-city items; (disabled in live too).
  • B6 Equipment/craftingmc-city/recipes.rs; add headless Craft action + tick (was gap 3).
  • B7 Per-building queues — dual-city-model unification (was gap 4).
  • [~] B8 event categories — 6/12 live wildfire/drought/volcanic/seismic/impact/tsunami (a18e1394b). Remaining: solar/glacial (need solar_forcing/glacial_forcing physics consumption); plague/pandemic/marine (need biosphere p3-27 ...); magical→G3.
  • Biosphere cluster → see p3-27 ... (ecology population + flora succession + marine).

Sequencing: B1/B2/B3 (self-contained turn-glue) parallelizable as separate modules; B6/B7 ride the dual-city-model; B8 ecological/marine events depend on p3-27. Each lands cargo+test-green, wired into step() serially.