fix: handling bdrs from ones

This commit is contained in:
Maximilian Keßler 2024-01-01 11:38:57 +01:00
parent ea723bdaff
commit 1d07cf67b1
Signed by: max
GPG Key ID: BCC5A619923C0BA5

View File

@ -53,6 +53,15 @@ def analyze_replay(instance: hanab_game.HanabiInstance, actions: List[hanab_game
outcomes.add(GameOutcome.bottom_deck) outcomes.add(GameOutcome.bottom_deck)
else: else:
if game.deck[game.progress:].count(card) == 1: if game.deck[game.progress:].count(card) == 1:
# Only one copy of this 1 remaining in the draw pile.
# See if it is in somebody's hand
num_copies_in_hands = 0
for hand in game.hands:
num_copies_in_hands += hand.count(card)
# Recall we evaluate the discard *before* the card is removed from the hand,
# so there is at least one present.
assert num_copies_in_hands > 0
if num_copies_in_hands == 1:
bdrs.append((card, game.draw_pile_size)) bdrs.append((card, game.draw_pile_size))
if card == game.deck[-1]: if card == game.deck[-1]:
outcomes.add(GameOutcome.bottom_deck) outcomes.add(GameOutcome.bottom_deck)