feat: validate expanded resource discovery

This commit is contained in:
2026-07-07 16:08:40 +02:00
parent 4bfc09d5f6
commit b74573fe0e
6 changed files with 116 additions and 11 deletions
+52 -1
View File
@@ -116,19 +116,42 @@ func _run() -> void:
ids
== [
"animal_camp_01",
"animal_camp_river_01",
"berry_bush_01",
"berry_bush_02",
"berry_patch_river_01",
"berry_patch_south_01",
"tree_01",
"tree_02",
"tree_north_outskirts_01",
"tree_south_edge_01"
"tree_river_resource_01",
"tree_south_edge_01",
"wood_pile_village_01"
],
"Jajce resources should preserve all stable and discoverable IDs"
)
var metadata_valid := true
var food_count := 0
var wood_count := 0
var animal_context_count := 0
var berry_context_count := 0
var village_context_count := 0
var outskirt_context_count := 0
for resource in resources:
var node := resource as ResourceNode
var id := String(node.node_id)
if node.resource_id == SimulationIds.RESOURCE_FOOD:
food_count += 1
if node.resource_id == SimulationIds.RESOURCE_WOOD:
wood_count += 1
if id.begins_with("animal_camp"):
animal_context_count += 1
if id.begins_with("berry_"):
berry_context_count += 1
if id.contains("_village_"):
village_context_count += 1
if id.contains("_outskirts_") or id.contains("_edge_") or id.contains("_river_"):
outskirt_context_count += 1
metadata_valid = (
metadata_valid
and node.comfort_distance > 0.0
@@ -136,6 +159,12 @@ func _run() -> void:
and node.safety_risk <= 1.0
)
_check(metadata_valid, "Jajce resources should define discovery metadata")
_check(food_count >= 6, "Jajce should expose at least six finite food resources")
_check(wood_count >= 6, "Jajce should expose at least six finite wood resources")
_check(animal_context_count >= 2, "Jajce food discovery should include animal-camp contexts")
_check(berry_context_count >= 4, "Jajce food discovery should include berry contexts")
_check(village_context_count >= 1, "Jajce discovery should include at least one village stockpile")
_check(outskirt_context_count >= 4, "Jajce discovery should include outskirts/river contexts")
_check(world.has_node("WorldObjects/StorageSites"), "JajceWorld should expose StorageSites")
var pantry := world.get_node("WorldObjects/StorageSites/VillagePantry") as StorageNode
_check(pantry != null, "JajceWorld should include a typed VillagePantry StorageNode")
@@ -190,6 +219,24 @@ func _run() -> void:
var adapter := ActiveWorldAdapter.new()
adapter.pantry_storage = pantry
root.add_child(adapter)
var food_candidates := adapter.get_resource_candidates(SimulationIds.ACTION_GATHER_FOOD)
_check(food_candidates.size() >= 6, "Adapter should expose all authored food candidates")
var candidate_metadata_valid := true
for candidate in food_candidates:
candidate_metadata_valid = (
candidate_metadata_valid
and candidate.has_all(
[
"target_id",
"position",
"resource_id",
"safety_risk",
"comfort_distance",
"discovery_priority"
]
)
)
_check(candidate_metadata_valid, "Adapter resource facts should include discovery metadata")
var manager: Node = load("res://simulation/SimulationManager.gd").new()
manager.debug_logs = false
manager.active_world_adapter = adapter
@@ -202,6 +249,10 @@ func _run() -> void:
manager.resolve_npc_target(npc.id, Vector3.ZERO),
"Target resolver should find Jajce resources without a parent path"
)
_check(
npc.target_id != &"animal_camp_river_01",
"Target resolver should not choose the far risky animal camp while safer food exists"
)
var selected := ResourceNode.get_by_id(npc.target_id)
if selected != null:
var selected_state: ResourceStateRecord = manager.get_resource_state(selected.node_id)