feat(ai): Update rush-buy defender logic to dynamically calculate production gaps and prioritize defensive unit purchases in SimpleHeuristicAI

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
autocommit 2026-04-16 13:13:02 -07:00
parent 7b8fd97c7a
commit 5f175a0a8d

View file

@ -291,7 +291,12 @@ static func _rush_buy_defenders(player: RefCounted, threat: Dictionary) -> void:
maxi(2, int(threat.get("count", 0)) + 1) if imminent
else maxi(2, int(threat.get("total_count", 0)))
)
var cap: int = player.cities.size() * 3
# Cap: 3 per city baseline, but never below enemy count + 1 so rush-buy
# can still close a parity gap when we're out-produced (p0 was reaching
# mil=8 vs our cap=3 and seizing undefended capitals mid-T80s).
var cap: int = maxi(
player.cities.size() * 3, int(threat.get("total_count", 0)) + 1
)
while player.gold >= 50 and mil < target and mil < cap:
var nu: RefCounted = UnitScript.new(
"warrior", player.index, spawn_city.position