feat: add witnessed knowledge and wind ambience

This commit is contained in:
Rijad Zuzo
2026-07-11 11:27:40 +02:00
parent 2ed93de6d1
commit 81409650df
72 changed files with 3001 additions and 606 deletions
+28 -27
View File
@@ -64,19 +64,14 @@ func _test_work_period_during_day() -> void:
manager.clock.cycle_duration_seconds = 240.0
manager.clock.elapsed_ticks = 100
var time_of_day: float = manager.clock.time_of_day()
_check(
time_of_day > 0.28 and time_of_day < 0.85,
"100 ticks should land in the work period"
)
_check(time_of_day > 0.28 and time_of_day < 0.85, "100 ticks should land in the work period")
var npc: SimNPC = manager.npcs[0]
npc.profession = SimulationIds.PROFESSION_WANDERER
npc.hunger = 20.0
npc.energy = 80.0
npc.home_position = npc.position
var selection := ActionSelectionSystem.new().select_action(
npc, manager.village, time_of_day
)
var selection := ActionSelectionSystem.new().select_action(npc, manager.village, time_of_day)
_check(selection != null, "Daytime should produce an action selection")
_check(
selection.action_id != SimulationIds.ACTION_SLEEP,
@@ -101,9 +96,7 @@ func _test_meal_period_hunger() -> void:
manager.village.food = 5.0
npc.home_position = npc.position
var selection := ActionSelectionSystem.new().select_action(
npc, manager.village, time_of_day
)
var selection := ActionSelectionSystem.new().select_action(npc, manager.village, time_of_day)
_check(selection != null, "Meal period should produce an action selection")
_check(
selection.action_id == SimulationIds.ACTION_WITHDRAW_FOOD,
@@ -129,10 +122,7 @@ func _test_sleep_restores_energy() -> void:
manager.simulate_tick()
_check(npc.task_complete, "Sleep should complete after its duration")
_check(
npc.energy > energy_before,
"Completing sleep should restore energy"
)
_check(npc.energy > energy_before, "Completing sleep should restore energy")
manager.free()
@@ -206,20 +196,26 @@ func _test_household_familiarity() -> void:
var d: SimNPC = manager.npcs[3]
var e: SimNPC = manager.npcs[4]
var a_to_b: RelationshipStateRecord = manager.relationship_system.get_relationship(a.id, b.id)
var b_to_a: RelationshipStateRecord = manager.relationship_system.get_relationship(b.id, a.id)
_check(a_to_b != null and b_to_a != null, "Nearby homes should create directed household ties")
if a_to_b != null:
_check(
(
is_equal_approx(a_to_b.get_familiarity(), 0.5)
and is_equal_approx(a_to_b.get_trust(), RelationshipStateRecord.NEUTRAL_TRUST)
),
"Household familiarity should start at baseline 0.5"
)
_check(
a.familiarity.has(b.id) and b.familiarity.has(a.id),
"NPCs with nearby homes should be mutual household members"
)
_check(
is_equal_approx(float(a.familiarity[b.id]), 0.5),
"Household familiarity should start at baseline 0.5"
)
_check(
c.familiarity.has(d.id) and d.familiarity.has(c.id),
(
manager.relationship_system.get_relationship(c.id, d.id) != null
and manager.relationship_system.get_relationship(d.id, c.id) != null
),
"Second household pair should also be familiar"
)
_check(
not a.familiarity.has(e.id),
manager.relationship_system.get_relationship(a.id, e.id) == null,
"Distant NPCs should not have household familiarity"
)
@@ -232,10 +228,15 @@ func _test_household_familiarity() -> void:
restored.restore_state_from_json(saved_json),
"Familiarity should survive save/load round-trip"
)
var ra: SimNPC = restored.npcs[0]
var restored_relationship: RelationshipStateRecord = (
restored.relationship_system.get_relationship(a.id, b.id)
)
_check(
ra.familiarity.size() > 0,
"Restored NPC should retain household familiarity"
(
restored_relationship != null
and is_equal_approx(restored_relationship.get_familiarity(), 0.5)
),
"Restored simulation should retain household familiarity"
)
manager.free()