Fix bugs around AI opponents.
This commit is contained in:
@@ -7,6 +7,18 @@ import (
|
||||
"github.com/greyson/super-auto-pets-board-game/internal/game"
|
||||
)
|
||||
|
||||
// deckHasPet reports whether a hypothetical deck still contains at least one
|
||||
// pet. A deck of only food (apples) can never field a fighter, so it is an
|
||||
// automatic loss — the bot must never voluntarily sell or trade its way there.
|
||||
func deckHasPet(deck []game.Card) bool {
|
||||
for _, c := range deck {
|
||||
if c.IsPet() {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// applyTemplateShopEffects mirrors the engine's shop-time triggers on a
|
||||
// hypothetical deck: buying an Otter really does come with an apple, and the
|
||||
// bot should value that. Only deck-changing effects matter here (coin
|
||||
@@ -240,6 +252,11 @@ func (b *Bot) decideShop(v *game.View, mem *Memory) *Action {
|
||||
nd = append(nd, cx.simApple())
|
||||
nd = cx.applyTemplateShopEffects(nd, s, game.TriggerSell)
|
||||
}
|
||||
// Never dump the last pet: an all-food deck loses on sight, so this
|
||||
// candidate is off the table no matter how the rollouts score.
|
||||
if !deckHasPet(nd) {
|
||||
continue
|
||||
}
|
||||
cands = append(cands, candidate{
|
||||
act: &Action{Type: "sell", Cards: ids},
|
||||
decks: [][]game.Card{nd},
|
||||
|
||||
Reference in New Issue
Block a user