feat(scenes): Add test coverage for lair counting in auto-play scenarios

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
autocommit 2026-04-15 20:26:00 -07:00
parent ff44eaf97e
commit a82fbba0db

View file

@ -346,6 +346,7 @@ func _process(_delta: float) -> void:
if btn != null:
print("AutoPlay: [world map] loaded")
_world_map = _find_node_by_name(get_tree().root, "WorldMap")
_count_lairs_on_map()
_state = "fix_start"
_frame = 0
if _frame > 600:
@ -394,6 +395,24 @@ func _process(_delta: float) -> void:
_frame = 0
func _count_lairs_on_map() -> void:
var game_map: RefCounted = GameState.get_game_map()
if game_map == null:
return
var counts: Dictionary = {}
for axial: Vector2i in game_map.tiles:
var tile: Resource = game_map.tiles[axial]
if tile == null:
continue
var lt: String = tile.lair_type if "lair_type" in tile else ""
if lt != "":
counts[lt] = int(counts.get(lt, 0)) + 1
var total: int = 0
for k: String in counts:
total += int(counts[k])
print("AutoPlay: lairs on map = %d %s" % [total, str(counts)])
# ── Start Position Fix ───────────────────────────────────────────────
func _fix_start_positions_if_needed() -> void:
@ -1338,6 +1357,7 @@ func _explore(unit: Variant, player: RefCounted, game_map: RefCounted) -> void:
any_valid = pos
var fog_count: float = 0.0
var food_hint: float = 0.0
var lair_adjacent: float = 0.0
var neighbors: Array[Vector2i] = HexUtilsScript.get_neighbors(pos)
for n: Vector2i in neighbors:
var norm: Vector2i = HexUtilsScript.normalize_position(
@ -1351,7 +1371,9 @@ func _explore(unit: Variant, player: RefCounted, game_map: RefCounted) -> void:
else:
var ny: Dictionary = tile.get_yields(player.index)
food_hint += float(int(ny.get("food", 0)))
var score: float = fog_count * 2.0 + food_hint * 3.0
if tile.lair_type != "":
lair_adjacent += 1.0
var score: float = fog_count * 2.0 + food_hint * 3.0 + lair_adjacent * 20.0
if founder_pos.x >= 0:
var dist: int = HexUtilsScript.hex_distance(pos, founder_pos)
if dist <= 5: