diff --git a/src/game/engine/src/modules/ai/simple_heuristic_ai.gd b/src/game/engine/src/modules/ai/simple_heuristic_ai.gd index b13c6dad..ccb6f0f1 100644 --- a/src/game/engine/src/modules/ai/simple_heuristic_ai.gd +++ b/src/game/engine/src/modules/ai/simple_heuristic_ai.gd @@ -367,8 +367,25 @@ static func _decide_production( var city: RefCounted = player.cities[city_index] var city_count: int = player.cities.size() + # Priority 0: Emergency garrison — no military at all means the next + # enemy stack wins uncontested before any wall is finished. A single + # warrior buys ~10 turns of breathing room at a fraction of walls' + # cost (20 vs 70). Only triggers when the player has zero military + # units across all cities, which in AoD arena matches is the turn-1 + # state since starting roster is founder + scout (no combat unit). + if military_count == 0: + var emergency_unit: String = _pick_buildable_military_unit_id( + city, player + ) + if not emergency_unit.is_empty(): + return _prod_unit(city_index, emergency_unit) + # Priority 1: Build walls if city has none (defense first) - if not city.has_building("walls") and city.can_build("walls", player): + var walls_built: bool = city.has_building("walls") + var walls_buildable: bool = city.can_build("walls", player) + if player.index == 1: + print("[AI_DBG] p1 c%d mil=%d fnd=%d walls_built=%s walls_buildable=%s" % [city_index, military_count, founder_count, walls_built, walls_buildable]) + if not walls_built and walls_buildable: var wdata: Dictionary = DataLoader.get_building("walls") if not wdata.is_empty(): return _prod_building(city_index, "walls")