Make the AI a little smarter.

This commit is contained in:
Greyson Parrelli
2026-07-24 16:20:45 -04:00
parent e25a85e394
commit 0a1e2f9bee
4 changed files with 93 additions and 4 deletions
+21
View File
@@ -160,6 +160,11 @@ type BattleResult struct {
Events []BattleEvent `json:"events"`
WinnerSeat int `json:"winnerSeat"` // -1 = draw
Trophies int `json:"trophies"` // awarded to the winner
// Survivors is each seat's remaining force at battle end: pets still in
// play plus any never reached in the stack. The loser is 0. It measures how
// decisive the result was — the margin the AI uses to prefer a lineup that
// fights harder, even in a battle it can't win.
Survivors []int `json:"survivors,omitempty"`
}
// setAsideRocks is a fainted pet's pending rock payout.
@@ -1312,5 +1317,21 @@ func (g *Game) runBattle() *BattleResult {
res.Trophies = 2
}
}
// Record each side's leftover force: a live pet in play plus any pets never
// reached in the stack. The loser lands on 0.
res.Survivors = make([]int, n)
for seat, s := range sides {
cnt := 0
if s.unit != nil && s.unit.Alive() {
cnt++
}
for _, c := range s.stack {
if c.IsPet() {
cnt++
}
}
res.Survivors[seat] = cnt
}
return res
}