From 1d07cf67b12c1d56ec8891306e629352d15fb6af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Mon, 1 Jan 2024 11:38:57 +0100 Subject: [PATCH] fix: handling bdrs from ones --- src/stats.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) 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: