From 1feeaccaec40b1362defd73234c37829eea66731 Mon Sep 17 00:00:00 2001 From: Natalie Date: Sun, 12 Apr 2026 14:43:44 -0700 Subject: [PATCH] =?UTF-8?q?feat(auto-play):=20build-then-attack=20strategy?= =?UTF-8?q?=20=E2=80=94=20accumulate=204=20warriors=20before=20marching?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Early game: found city, build warriors, keep military at home for defense - Only scout explores (other units garrison) - Once 4+ warriors accumulated, march all toward nearest enemy city - Should survive enemy attacks with numerical advantage Co-Authored-By: Claude Opus 4.6 (1M context) --- src/game/engine/scenes/tests/auto_play.gd | 31 ++++++++++++++++++----- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/game/engine/scenes/tests/auto_play.gd b/src/game/engine/scenes/tests/auto_play.gd index ba53a200..0f0e8981 100644 --- a/src/game/engine/scenes/tests/auto_play.gd +++ b/src/game/engine/scenes/tests/auto_play.gd @@ -189,19 +189,38 @@ func _play_turn() -> void: if _turn_count <= 5 or _turn_count % 10 == 0: print(" Turn %d: %d units, %d cities" % [_turn_count, unit_count, city_count]) - # 1. Found city + # 1. Found city on turn 1 if city_count == 0: _try_found_city(player, game_map) - # 2. Queue production + # 2. Always queue warriors for c: Variant in player.cities: _manage_production(c) - # 3. Move units (copy to avoid mutation during iteration) + # 3. Strategy: build up army, then attack + var military_count: int = 0 + for u: Variant in player.units: + if u.is_alive() and u.get("can_found_city") != true: + military_count += 1 + var units_snapshot: Array = player.units.duplicate() - for u: Variant in units_snapshot: - if u.is_alive() and u.movement_remaining > 0: - _command_unit(u, player, game_map) + + if military_count >= 4: + # ATTACK PHASE: march all units toward nearest enemy city + var target: Vector2i = _find_attack_target(player) + if target != Vector2i(-1, -1): + if _turn_count % 10 == 0: + print(" ATTACK: %d warriors marching to %s" % [military_count, target]) + for u: Variant in units_snapshot: + if u.is_alive() and u.movement_remaining > 0 and u.get("can_found_city") != true: + _move_toward(u, target, game_map) + else: + # BUILD PHASE: keep units at home, only scout explores + for u: Variant in units_snapshot: + if u.is_alive() and u.movement_remaining > 0: + if u.type_id == "dwarf_scout": + _explore(u, player, game_map) + # Warriors stay at city for defense func _try_found_city(player: RefCounted, _game_map: RefCounted) -> void: