Commit Graph

20 Commits

Author SHA1 Message Date
admin 363620b731 refactor: move resource authority into simulation 2026-07-05 13:26:19 +02:00
admin 30cac28fc0 feat: add versioned simulation state records 2026-07-05 12:52:07 +02:00
admin 37610242bf feat: add deterministic simulation foundation
Replace implicit randomness with seeded per-NPC RandomNumberGenerator
streams so the same seed always produces the same scenario outcome.

- Add SimulationClock (RefCounted): explicit fixed-step clock that
  converts frame delta into simulation ticks while preserving sub-tick
  remainder; replaces raw _process tick_timer accumulation
- Add simulation_seed export (int=1337) to SimulationManager; drive
  per-NPC RNG streams via seed + npc_id + stream_id derivation
  (stream 0=init, stream 1=wander)
- Add get_wander_offset(npc_id) to SimulationManager so wander targets
  are deterministic per seed; WorldViewManager calls it instead of
  local randf_range()
- Add get_state_snapshot() and get_state_checksum() to SimulationManager
  for headless verification and future save/load
- Convert SimNPC/SimVillage const DEBUG_LOGS to instance var debug_logs
  so headless tests can silence output without recompilation
- Pass RandomNumberGenerator through SimNPC._init() instead of using
  global randf_range() for hunger/energy/position/scoring noise
- Remove obsolete farm_zone and forest_zone exports from
  WorldViewManager and their marker/tree scene children from main.tscn;
  NPC gather tasks use ResourceNode exclusively
- Rename TaskZone container to ActivityMarkers in main.tscn and update
  all scene paths (player, WVM, tests) to match
- Add headless deterministic_simulation_test.gd: verifies clock
  accuracy, same-seed equality, different-seed divergence, and
  24-tick scenario checksum without loading main.tscn
2026-07-05 11:23:12 +02:00
admin 556d0fdc26 feat: add Jajce world scaffold 2026-07-04 21:06:57 +02:00
admin 326df51cbe feat: add player resource node harvesting 2026-07-04 19:47:31 +02:00
admin b8752f8835 feat: add navigation_failed signal with time-based stuck detection and simulation pipeline
NpcVisual:
- Add navigation_failed(sim_id) signal distinct from arrived_at_target
  so the simulation layer can distinguish genuine arrival from failure
- Replace integer stuck_counter with delta-based stuck_time and
  exported stuck_timeout (1.5s) for frame-rate-independent detection
- Add path_request_id / path_pending mechanism to reject stale
  async path results when a new target is set or NPC dies
- On empty path or stuck movement, emit navigation_failed instead
  of arriving; only emit arrived_at_target when truly close to target
- Reduce arrival_distance back to 0.6 now that navigation_failure
  is properly signalled (no longer needed as a workaround)
- clamp arrival_distance reference in apply_dead_visual_state

SimNPC:
- Remove retry_count (replaced by navigation_failed signal pathway)
- Move last_task assignment from set_task() to task completion in
  SimulationManager so it reflects the task that actually finished

SimulationManager:
- Add notify_npc_navigation_failed(): release reservation, record
  last_task, send NPC to wander for 2s, emit task_changed signal
- Add notify_npc_target_unavailable() as public alias of above
- Guard extraction with node.reserved_by == npc.id to prevent
  stale/illegitimate extraction when reservation is lost
- Guard fallback zone task completion (apply_npc_task) so it only
  fires for non-resource tasks (gather_food/wood with no target
  silently skip instead of applying zone values)
- Remove retry_count safety net (fully replaced by signal pipeline)

WorldViewManager:
- Connect navigation_failed signal in spawn_npc_visual()
- Skip target assignment for empty/idle/dead task states
- When no resource node available for gather_food/wood, call
  notify_npc_target_unavailable() so NPC wanders instead of idling
- Add _on_npc_visual_navigation_failed handler delegating to
  SimulationManager.notify_npc_navigation_failed()
- Remove retry_count references
2026-07-04 19:24:30 +02:00
admin 1837bc0d2d fix: detect duplicate ResourceNode node_id and use interaction_point for distance calc
- Push error and disable node when duplicate node_id is registered
  to prevent silent conflict during find_available()
- Use interaction_point.global_position instead of self.global_position
  in find_available() so distance is measured to the marker NPCs
  actually navigate toward
2026-07-04 19:24:19 +02:00
admin 41bfc8d90a fix: empty-path re-entrancy, retry_count reset, := to = for Variant 2026-07-03 18:51:13 +02:00
admin 0dfaa06f9c fix: remove invalid StringName cast from dictionary get 2026-07-03 18:28:06 +02:00
admin 8049c52e0f fix: use Variant assignment for _try_get_resource_target return type 2026-07-03 18:26:50 +02:00
admin 9cd38a1adb feat: add ResourceNode system with target selection and reservation
Phase 1-2 of the ResourceNode migration plan:

- Create ResourceNode class (world/resource_nodes/) with extraction,
  reservation, nearest-available selection, and debug label
- Place 4 resource instances in main.tscn (2 berry bushes, 2 trees)
- Add target_id to SimNPC for tracking which node an NPC is using
- Add set_npc_target_id and release_npc_reservation to SimulationManager
  with cleanup on task change, completion, and death
- Update WorldViewManager to query available ResourceNodes first,
  falling back to zone markers with a logged warning
2026-07-03 18:18:51 +02:00
Rijad Zuzo b5e2493c2a feat: add proper death from starvation and survival tasks urgency 2026-06-21 23:37:58 +02:00
Rijad Zuzo 052b36a4e7 feat: add completition of work only after work is done 2026-06-21 00:11:34 +02:00
Rijad Zuzo 852d10f7ae feat: add initial starvation consequence 2026-06-20 18:18:00 +02:00
Rijad Zuzo d185dcacf3 feat: add consequence with modifiers for properties 2026-06-20 17:12:10 +02:00
Rijad Zuzo f251423f62 feat: add ui labels to display village state 2026-06-19 12:08:48 +02:00
Rijad Zuzo c37eb9bd3d feat: add behaviour events from the simulation results 2026-06-19 10:42:11 +02:00
Rijad Zuzo af3495f4e3 feat: add npc path finding to the zones based on needs 2026-06-19 10:02:42 +02:00
Rijad Zuzo e2549ac50c feat: add movment based on needs with themed zones 2026-06-19 08:08:17 +02:00
Rijad Zuzo a3ad8d8a07 feat: add npc simulation, instancing and visual scene 2026-06-18 11:12:08 +02:00