diff --git a/.project/objectives/objectives.json b/.project/objectives/objectives.json index c5fd30fd..c0f462fe 100644 --- a/.project/objectives/objectives.json +++ b/.project/objectives/objectives.json @@ -1,5 +1,5 @@ { - "generated_at": "2026-06-08T03:28:41Z", + "generated_at": "2026-06-08T04:06:43Z", "totals": { "done": 243, "in_progress": 1, diff --git a/.project/objectives/p2-80-mc-worldsim-integration.md b/.project/objectives/p2-80-mc-worldsim-integration.md index 41101b33..9941e9d7 100644 --- a/.project/objectives/p2-80-mc-worldsim-integration.md +++ b/.project/objectives/p2-80-mc-worldsim-integration.md @@ -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** — *mechanism done; live-game visibility blocked upstream.* Climate fields + flora succession + biome reclass are *already* drawn each turn by `hex_renderer.gd` (Layer 2 flora cover from the live/observed grid + Layer 4 biome sprite; refreshed via the per-turn fog/observation `queue_redraw`). **Fauna population** is now surfaced by a new `fauna_overlay_renderer.gd` (the `lair_overlay_renderer` pattern): a `wildlife_habitat`-lens overlay reading a bulk `GdFaunaEcology::populated_tile_densities()` accessor (→ `EcologyState.tile_densities()`), refreshed on the new `EventBus.worldsim_updated` emitted by `turn_manager` after the ecology tick. The render path is verified: GUT `test_fauna_overlay.gd` 5/5 (113 populated tiles; `tile_densities()` matches engine 113↔113) and proof `fauna_overlay_proof.tscn` shows fauna 4→113 tiles over 12 turns rendered live (green→yellow density). Commits `8e21f48a1` + `0c7dbb7d6`. **BUT bullet 6's "visible *in the playable game*" is NOT yet met:** a discriminating probe (`test_emergence_probe.gd`, emergence-only, no seeding) found the live engine produces **0 populated tiles over 60 turns** — the live game never seeds fauna (`EcologyInitializer` is dead code) and emergence draws from `species_library`, which the live path left empty (`register_species` fills only the registry). Fixed the empty-library half this commit (new `GdFaunaEcology::load_species_library_from_json`, wired in `EcologyState._ensure_species_registered`), but emergence still didn't bootstrap on a synthetic flora-less grid — `check_emergence` gates on trophic structure (herbivores need vegetation). Both the renderer and the seeded data prove the render path; the world being *alive in real play* now hinges on the live-population fix below. Tracked as a follow-up (live fauna bootstrapping: initial seeding and/or emergence-on-real-worldgen verification). +- ✓ **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). - ◻ `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 diff --git a/src/game/engine/src/rendering/fauna_overlay_renderer.gd b/src/game/engine/src/rendering/fauna_overlay_renderer.gd index 65e7fe26..d4381db0 100644 --- a/src/game/engine/src/rendering/fauna_overlay_renderer.gd +++ b/src/game/engine/src/rendering/fauna_overlay_renderer.gd @@ -71,12 +71,16 @@ func _draw() -> void: # proof scenes) shows everything. var fog_off: bool = EnvConfig.get_bool("FORCE_DISABLE_FOGOFWAR") var game_map: RefCounted = GameState.get_game_map() - var view_idx: int = _view_player_index() + var gate_fog: bool = not fog_off and game_map != null + # Resolve the viewing player only when fog-gating actually runs (avoids + # touching GameState.get_current_player() in headless/test contexts with no + # active game). + var view_idx: int = _view_player_index() if gate_fog else 0 for pos: Vector2i in _densities: var density: float = float(_densities[pos]) if density <= 0.0: continue - if not fog_off and game_map != null: + if gate_fog: var tile: RefCounted = game_map.get_tile(pos) # Unexplored (visibility 0) tiles stay dark — no fauna leak. Explored # tiles (visible or fogged) show the density; the player has been there.