feat(auto-play): build-then-attack strategy — accumulate 4 warriors before marching
- 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) <noreply@anthropic.com>
This commit is contained in:
parent
241391ddb4
commit
1feeaccaec
1 changed files with 25 additions and 6 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue