diff --git a/src/game/engine/scenes/tests/auto_play.gd b/src/game/engine/scenes/tests/auto_play.gd index 5de6e956..0ae2b007 100644 --- a/src/game/engine/scenes/tests/auto_play.gd +++ b/src/game/engine/scenes/tests/auto_play.gd @@ -276,16 +276,20 @@ func _play_turn() -> void: _locked_target = _find_attack_target(player) _target_stuck_turns = 0 # Detect stuck warriors — if army hasn't moved in 20 turns, pick new target - var army_pos: Vector2i = Vector2i.ZERO + # Track closest warrior distance to target + var min_dist: int = 999 for u_chk: Variant in units_snapshot: if u_chk.is_alive() and u_chk.get("can_found_city") != true: - army_pos = u_chk.position - break - if army_pos == _last_army_pos: + var d: int = HexUtilsScript.hex_distance(u_chk.position, _locked_target) + if d < min_dist: + min_dist = d + if min_dist <= 1: + _target_stuck_turns = 0 # adjacent — attacking, not stuck + elif min_dist >= _last_army_pos.x: # reusing x as last_distance _target_stuck_turns += 1 else: _target_stuck_turns = 0 - _last_army_pos = army_pos + _last_army_pos = Vector2i(min_dist, 0) if _target_stuck_turns >= 20: print(" STUCK: army can't reach %s, re-targeting" % _locked_target) _locked_target = Vector2i(-1, -1)