feat: add person history and trust reactions

This commit is contained in:
Rijad Zuzo
2026-07-12 11:42:10 +02:00
parent 99b8146f75
commit 9fcf6a0a58
19 changed files with 543 additions and 90 deletions
+44 -4
View File
@@ -4,6 +4,7 @@ const SimulationEventLogScript := preload("res://simulation/events/SimulationEve
const VillageEconomyScript := preload("res://simulation/economy/VillageEconomy.gd")
const RelationshipSystemScript := preload("res://simulation/relationships/RelationshipSystem.gd")
const EventKnowledgeSystemScript := preload("res://simulation/knowledge/EventKnowledgeSystem.gd")
const SimulationManagerScript := preload("res://simulation/SimulationManager.gd")
func test_storage_never_accepts_more_than_its_capacity() -> void:
@@ -211,9 +212,48 @@ func test_knowledge_retention_is_bounded_stable_and_importance_ranked() -> void:
var ranked_system := EventKnowledgeSystemScript.new()
var ranked_records: Array[KnownEventStateRecord] = [
KnownEventStateRecord.create(1, 1, SimulationIds.KNOWLEDGE_ACQUISITION_WITNESSED, -1, 10),
KnownEventStateRecord.create(1, 2, SimulationIds.KNOWLEDGE_ACQUISITION_WITNESSED, -1, 20),
KnownEventStateRecord.create(1, 10, SimulationIds.KNOWLEDGE_ACQUISITION_WITNESSED, -1, 5),
KnownEventStateRecord.create(1, 20, SimulationIds.KNOWLEDGE_ACQUISITION_WITNESSED, -1, 20),
KnownEventStateRecord.create(
1,
30,
SimulationIds.KNOWLEDGE_ACQUISITION_COMMUNICATED,
2,
20,
SimulationIds.KNOWLEDGE_ACQUISITION_WITNESSED
),
KnownEventStateRecord.create(1, 40, SimulationIds.KNOWLEDGE_ACQUISITION_LEGACY, -1, 10),
]
ranked_system.restore(ranked_records)
var lasting_event_ids: Array[int] = [1]
assert_eq(ranked_system.get_communicable_event_ids(1, lasting_event_ids), [1, 2])
var lasting_event_ids: Array[int] = [10]
assert_eq(ranked_system.get_retained_event_ids(1, lasting_event_ids, 0), [10, 30, 20, 40])
assert_eq(ranked_system.get_retained_event_ids(1, lasting_event_ids, 2), [10, 30])
assert_eq(ranked_system.get_communicable_event_ids(1, lasting_event_ids), [10, 20])
var objective_events: Array[EconomicEventRecord] = []
for event_id in [10, 20, 30, 40]:
objective_events.append(
EconomicEventRecord.create(
event_id,
SimulationIds.EVENT_STORAGE_DEPOSITED,
0,
0,
SimulationIds.npc_inventory_id(0),
SimulationIds.STORAGE_VILLAGE_PANTRY,
SimulationIds.RESOURCE_FOOD,
1.0
)
)
var manager := SimulationManagerScript.new()
manager.event_log.restore(objective_events, 41)
manager.event_knowledge_system.restore(ranked_records)
var relationships: Array[RelationshipStateRecord] = [
RelationshipStateRecord.create(1, 0, 0.5, 0.65, 10)
]
manager.relationship_system.restore(relationships)
var retained_events: Array[EconomicEventRecord] = manager.get_retained_memory_events(1, 3)
var retained_ids: Array[int] = []
for event in retained_events:
retained_ids.append(int(event.data["event_id"]))
assert_eq(retained_ids, [10, 30, 20])
manager.free()