Make the AI a little smarter.
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user