fix(@projects/@magic-civilization): 🐛 fix fauna rendering and cold-start bug

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
Natalie 2026-06-07 21:25:42 -07:00
parent 5582c5f90d
commit 7dd4f6c894
3 changed files with 12 additions and 6 deletions

View file

@ -1,5 +1,5 @@
{
"generated_at": "2026-06-08T04:06:43Z",
"generated_at": "2026-06-08T04:17:29Z",
"totals": {
"done": 243,
"in_progress": 1,

View file

@ -64,7 +64,7 @@ hydrology re-solve) hook the terraforming cascade into the same step.
- ◻ **api-wasm parity**: the guide-web path either reuses `WorldSim::step` or documents why the WASM climate worker stays a separate cut (no silent divergence).
- ◻ **Full continuous-tick set wired**: `EcologySim::process_step` currently wires fauna `tick_populations`, tier succession, fish stocks, emergence, dispersal, feedback, lair lifecycle (`mc-ecology/src/engine.rs:276`). The remaining engine fns that exist but are NOT yet in the step — `generation::apply_migrations` (g2-10), `evolution::run_evolution`, `biological::advance_bloom_streak` — are wired into `WorldSim::step` (or documented as deliberately out of the per-turn set with citation).
- ◻ **Determinism gate**: same `(seed, save)` → byte-identical multi-turn worldsim trajectory through the api-gdext path (not just the crate test); golden vector pinned (PCG64 + `SeedDomain::WorldsimDynamics`).
- **Render hook***the living world is visible in real play.* Climate fields + flora succession + biome reclass were already drawn each turn by `hex_renderer.gd` (Layer 2 flora cover + Layer 4 biome sprite, refreshed via the per-turn fog/observation `queue_redraw`). **Fauna population** is now surfaced by `fauna_overlay_renderer.gd` (the `lair_overlay_renderer` pattern): a `wildlife_habitat`-lens overlay reading bulk `GdFaunaEcology::populated_tile_densities()` (→ `EcologyState.tile_densities()`), refreshed on `EventBus.worldsim_updated` (emitted by `turn_manager` after the ecology tick), and **fog-gated** so it never leaks fauna on unexplored tiles. **The barren-world bug behind this is fixed:** the live engine never seeded fauna (`EcologyInitializer` was dead code) and emergence is a deliberate slow trickle (`emergence_rate_base` = 0.001) gated on flora-derived `habitat_suitability` (≈0 at genesis) — it cannot cold-start an empty map. Added world-genesis **seeding**: `emergence::seed_base_trophic` (reuses the emergence pickers/generators, bypasses the rarity roll, base trophic only — herbivore+detritivore on land / filter-feeder in water, gated on stable `quality` not flora-derived suitability) → `EcologyEngine::seed_initial``GdFaunaEcology::seed_initial_populations`, wired into `EcologyState.tick` (lazy, first-tick, skips already-populated tiles so loads aren't double-seeded). Also populated the emergence `species_library` (`load_species_library_from_json`) so ongoing emergence works. **Verified end-to-end on a REAL worldgen autoplay (seed 5, 25 turns):** seeding bootstrapped **960 populated tiles at genesis**, which the LV dynamics regulated to a stable **~376 tiles** (`fauna_tiles` in `turn_stats.jsonl`, instrumented in `auto_play.gd`) — a living, self-regulating world, no synthetic crutch. Render path proven by GUT `test_fauna_overlay.gd` 5/5 + seeding by `test_fauna_emergence_live.gd` (192 tiles, survives 40 turns) + the `fauna_overlay_proof.tscn` screenshot (now faithful to production since the live game seeds identically).
- **Render hook***render mechanism + live population verified separately; the fog-gated overlay rendering the live distribution in one real-game artifact is not yet captured.* Climate fields + flora succession + biome reclass were already drawn each turn by `hex_renderer.gd` (Layer 2 flora cover + Layer 4 biome sprite, refreshed via the per-turn fog/observation `queue_redraw`). **Fauna population** is now surfaced by `fauna_overlay_renderer.gd` (the `lair_overlay_renderer` pattern): a `wildlife_habitat`-lens overlay reading bulk `GdFaunaEcology::populated_tile_densities()` (→ `EcologyState.tile_densities()`), refreshed on `EventBus.worldsim_updated` (emitted by `turn_manager` after the ecology tick), and **fog-gated** so it never leaks fauna on unexplored tiles. **Honest gap:** the render path (`test_fauna_overlay.gd` 5/5) and the live population (960→376 real autoplay) are each proven, but in *separate* harnesses — no single artifact shows the fog-gated overlay drawing the real ~376-tile live distribution. The fog-gate branch in `_draw()` is also not exercised end-to-end: headless autoplay forces `FORCE_DISABLE_FOGOFWAR`, so the branch is dead in every automated run. Closing this bullet needs a real interactive (fogged) playthrough screenshot, which the headless apricot harness cannot produce. **The barren-world bug behind this is fixed:** the live engine never seeded fauna (`EcologyInitializer` was dead code) and emergence is a deliberate slow trickle (`emergence_rate_base` = 0.001) gated on flora-derived `habitat_suitability` (≈0 at genesis) — it cannot cold-start an empty map. Added world-genesis **seeding**: `emergence::seed_base_trophic` (reuses the emergence pickers/generators, bypasses the rarity roll, base trophic only — herbivore+detritivore on land / filter-feeder in water, gated on stable `quality` not flora-derived suitability) → `EcologyEngine::seed_initial``GdFaunaEcology::seed_initial_populations`, wired into `EcologyState.tick` (lazy, first-tick, skips already-populated tiles so loads aren't double-seeded). Also populated the emergence `species_library` (`load_species_library_from_json`) so ongoing emergence works. **Verified end-to-end on a REAL worldgen autoplay (seed 5, 25 turns):** seeding bootstrapped **960 populated tiles at genesis**, which the LV dynamics regulated to a stable **~376 tiles** (`fauna_tiles` in `turn_stats.jsonl`, instrumented in `auto_play.gd`) — a living, self-regulating world, no synthetic crutch. Render path proven by GUT `test_fauna_overlay.gd` 5/5 + seeding by `test_fauna_emergence_live.gd` (192 tiles, survives 40 turns) + the `fauna_overlay_proof.tscn` screenshot (now faithful to production since the live game seeds identically).
- ◻ `cargo test` green (incl. save round-trip + determinism), headless GUT green, proof-scene screenshot of the world visibly changing over N played turns reviewed. *(Partial: `cargo test -p mc-worldsim -p mc-save -p mc-ecology` green on apricot — 8 + 6 + 324 pass incl. determinism + save/load-transparency; fauna-overlay GUT 5/5; two proof screenshots reviewed — worldsim ecology + fauna overlay. Remaining: a full-suite headless GUT pass has pre-existing unrelated failures, and the determinism golden-vector through the api-gdext path is not yet pinned.)*
## Non-goals

View file

@ -93,11 +93,17 @@ func _draw() -> void:
draw_colored_polygon(_hex_at(pos), color)
## The player whose vision gates the overlay — the local/current player viewing
## the map. Falls back to slot 0 if no current player is resolvable.
## The player whose vision gates the overlay — the local HUMAN viewer, so the
## lens shows the map from the human's perspective regardless of whose turn is
## resolving (the overlay refreshes on worldsim_updated at end-of-turn, when the
## turn-cycling current player is NOT necessarily the viewer). Falls back to the
## current player, then slot 0, for AI-only / spectator runs.
func _view_player_index() -> int:
var p: RefCounted = GameState.get_current_player()
return int(p.index) if p != null else 0
for p: Variant in GameState.players:
if p != null and bool(p.get("is_human")):
return int(p.get("index"))
var cur: RefCounted = GameState.get_current_player()
return int(cur.index) if cur != null else 0
## Translate the shared flat-top hex polygon to the given tile's pixel origin.