From aeda438bf3204b944d6977cf73a3549677a7a62f Mon Sep 17 00:00:00 2001 From: Natalie Date: Sun, 12 Apr 2026 15:29:43 -0700 Subject: [PATCH] feat(auto-play): defensive counter-attacks + garrison until 5 warriors - Build phase: attack adjacent enemies before fortifying (counter-attack) - Only march when 5+ warriors accumulated (no more premature attacks) - Warriors at city fortify for defense bonus AND fight back Co-Authored-By: Claude Opus 4.6 (1M context) --- src/game/engine/scenes/tests/auto_play.gd | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/game/engine/scenes/tests/auto_play.gd b/src/game/engine/scenes/tests/auto_play.gd index 15338c8e..2a11e4bc 100644 --- a/src/game/engine/scenes/tests/auto_play.gd +++ b/src/game/engine/scenes/tests/auto_play.gd @@ -208,7 +208,7 @@ func _play_turn() -> void: var city_pos: Vector2i = player.cities[0].position if not player.cities.is_empty() else Vector2i.ZERO - if military_count >= 1 and _turn_count >= 30: + if military_count >= 5: # ATTACK PHASE: lock onto one target and march until it's destroyed if _locked_target == Vector2i(-1, -1): _locked_target = _find_attack_target(player) @@ -240,7 +240,7 @@ func _play_turn() -> void: u.fortified_turns = 0 _move_toward(u, target, game_map) else: - # BUILD PHASE: fortify warriors at city, only scout explores + # BUILD PHASE: fortify at city, attack any adjacent enemies for u: Variant in units_snapshot: if not u.is_alive() or u.movement_remaining <= 0: continue @@ -249,12 +249,15 @@ func _play_turn() -> void: if u.type_id == "dwarf_scout" and _turn_count <= 15: _explore(u, player, game_map) else: - # Fortify at city for defense bonus + # First: attack adjacent enemies (defensive counter-attack) + _try_attack_adjacent(u, game_map) + if not u.is_alive() or u.movement_remaining <= 0: + continue + # Then: fortify at city if u.position == city_pos: u.is_fortified = true u.movement_remaining = 0 else: - # Move back to city _move_toward(u, city_pos, game_map)