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) <noreply@anthropic.com>
This commit is contained in:
Natalie 2026-04-12 15:29:43 -07:00
parent 156efa5692
commit aeda438bf3

View file

@ -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)