Files
Soul_Game/docs/SPEC_addendum_exploration.md
mmcghen 10e772d087 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>
2026-07-21 21:17:24 -04:00

70 lines
5.8 KiB
Markdown

# Soul Reincarnation World Simulation — Exploration & Town Distance Addendum
*Builds on the original design spec. Covers town isolation, needs-based exploration, and personal resource-node knowledge.*
---
## 1. Problem Being Solved
Current state: all NPCs across all four towns can interact from tick one, before settlements have even formed, and NPCs have global knowledge of every resource node's location. This collapses the towns into one shared pool instead of four distinct cultural "echo chambers" that only make contact through deliberate exploration.
Goal: towns should develop in relative isolation first, with cross-town contact emerging naturally as a *result* of resource pressure and exploration — not something possible from the very first tick.
---
## 2. Town Distance / Isolation
- No artificial hard block on socializing is wanted — the fix should come from constraining *what NPCs know and can reach*, not from disabling interaction mechanically.
- Each town should function as its own local loop (gather/build/trade/socialize) until something pushes individuals beyond it.
- Cross-town contact becomes a real, observable event — first contact happens because someone *found* the other town, not because the simulation allowed it by default.
---
## 3. Needs-Based Exploration (not random chance)
Rejected: random per-NPC "wander" chance each day.
**Chosen approach:** exploration is driven by real resource supply/demand pressure, using the same soul-weighted decision system already used for gathering and trading. When an NPC's (or town's) locally known resources can't meet demand, venturing outward becomes the logical next step in the state machine — not a dice roll.
### How each town's soul philosophy should shape *when* and *how* they push outward:
- **South (Nature):** sustainable harvesting means local resources rarely deplete. They venture out **late**, mainly once population growth outpaces what the home area can regenerate. Reads as "we've outgrown this valley," not resource panic.
- **West (Materialistic):** status competition drives overconsumption of visible/display materials faster than regen. They push outward **early**, chasing new sources of status-signaling resources.
- **East (Selfish):** hoarding causes uneven, fast local depletion in pockets. Expect **individual** NPCs — not the whole town — to venture out well ahead of general need, as opportunistic scouts.
- **North (Generational):** expansion is driven by needing land for new family compounds as generations multiply. Their venturing is **deliberate/planned**, not reactive to scarcity.
### Mechanical shape
- Resource nodes: finite with regen (already implemented).
- Each soul type gets a consumption-rate multiplier against the shared regen rate.
- When an NPC's (or town's) local supply/demand ratio crosses a threshold, gathering-state logic starts pathing beyond the home radius toward the nearest *known* unclaimed resource — falling out of the existing soul-weighted decision system rather than requiring new randomness.
---
## 4. Personal Resource-Node Knowledge (No Global Map Access)
Current state: NPCs have full knowledge of all node locations in the world, so they beeline to the optimal node instead of exploring.
**Fix:** NPCs should only be able to act on resource nodes they have personally discovered. Discovery becomes the actual bottleneck driving exploration, not just resource pressure alone.
### Structure
- **Known-nodes list (per NPC):** an NPC's gathering/building logic only ever queries nodes on *their own* known list — never the global resource table.
- **Sensing radius:** a small "currently visible" radius each tick; any node that enters this radius gets added to the NPC's known-nodes list.
- **Wander-when-starved fallback:** when an NPC's known nodes are depleted/insufficient and nothing new is in sensing range, that's the concrete trigger for venture-out behavior — move outward (biased away from town center / toward unexplored territory) until sensing radius picks something up.
- **Reuse of existing systems:** the game's NPC class already tracks personal knowledge for trade relationships. Known-nodes should extend that same "personal knowledge" pattern rather than introduce a new system.
- Open question to resolve during implementation: is trade knowledge currently keyed NPC-to-NPC (trust relationships) or NPC-to-entity (things known to exist)? If the latter, known-nodes can likely reuse the identical data structure with a different entity type. If the former, known-nodes probably needs its own parallel structure, since location memory and trust-relationship memory are conceptually distinct.
- **Knowledge spread via proximity/social diffusion:** once one NPC discovers a new node, nearby townsfolk can learn about it through the same proximity/social diffusion mechanic already designed for skill/craft knowledge transfer (see original spec, Section 5). Discovery spreads organically through a town rather than becoming instantly global. No new diffusion system needs to be built — this is the same rule applied to a second knowledge type (locations, not skills).
---
## 5. Summary of Design Consistency
Both mechanics in this addendum deliberately reuse existing systems rather than introducing new ones:
| New behavior | Reuses |
|---|---|
| Needs-based venture-out trigger | Existing soul-weighted state machine (gathering/trading logic) |
| Per-NPC known-nodes memory | Existing personal-knowledge structure (currently used for trade) |
| Node-discovery spread between NPCs | Existing proximity/social knowledge-diffusion design (Section 5 of main spec) |
This keeps the engine soul-type-agnostic and modular, consistent with the original MVP design intent: new behaviors should come from tuning weights and thresholds on existing systems, not from bolting on new mechanics per feature.