Run 15: known-nodes exploration (addendum stage 1), per-town debug, O(n^2) fix
Exploration addendum stage 1: per-NPC known-nodes. NPCs gather only from resources they've personally sensed (radius 22) or been told about; founders seed with home ground, children inherit parents' maps, node knowledge diffuses between neighbors like skills. Starving NPCs venture outward and sense as they go - non-random needs-driven exploration, the seed of first contact. Repopulation preserved (seeding + survival food fallback): all towns fed, population stable 86-109 over 240 days. Debug screen rebuilt: the ~68-row per-villager roster (overflowing at four-town scale) replaced with a per-town summary - pop, fed%, knowledge, debris, state breakdown, buildings, culture-colored, plus world births/deaths. Scales to any population. Performance: added phase timers and measured instead of guessing - npc.Tick was 94% of cost, O(n^2) via TickResting calling RestingOccupancy (full population scan) per building per resting NPC. Fixed with a once-per-tick occupancy cache on Building. npc phase ~4x faster and now linear; full 240-day four-town run in 180s, faster than the pre-exploration baseline. Profiling scaffolding removed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -94,6 +94,11 @@ public class Building
|
||||
|
||||
/// <summary>How many can sleep here. Expansion adds beds — growth has a
|
||||
/// human meaning, not just a bigger square.</summary>
|
||||
/// <summary>Sleepers here, recomputed once per tick by GameManager —
|
||||
/// so resting NPCs read a cached count instead of each re-scanning the
|
||||
/// whole population per building (that was the sim's O(n²) hot spot).</summary>
|
||||
public int Occupancy;
|
||||
|
||||
public int RestCapacity =>
|
||||
Kind == BuildingKind.Shelter && IsComplete && !IsRuined ? 3 + Modules : 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user