diff --git a/src/stats.py b/src/stats.py index d73d8ce..2734080 100644 --- a/src/stats.py +++ b/src/stats.py @@ -53,9 +53,18 @@ def analyze_replay(instance: hanab_game.HanabiInstance, actions: List[hanab_game outcomes.add(GameOutcome.bottom_deck) else: if game.deck[game.progress:].count(card) == 1: - bdrs.append((card, game.draw_pile_size)) - if card == game.deck[-1]: - outcomes.add(GameOutcome.bottom_deck) + # 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)) + if card == game.deck[-1]: + outcomes.add(GameOutcome.bottom_deck) for action in actions: if action.type == hanab_game.ActionType.Discard: