def test_removes_specified_number_of_cards_from_deck(self): ace = Card(rank="Ace", suit="Spades"), eight = Card(rank="8", suit="Diamonds") cards = [ace, eight] deck = Deck() deck.add_cards(cards) self.assertEqual(deck.remove_cards(1), [ace]) self.assertEqual(deck.cards, [eight])
def test_removes_specified_number_of_cards_from_deck(self): two = Card(rank="2", suit="Clubs"), ace = Card(rank="Ace", suit="Spades") cards = [two, ace] deck = Deck() deck.add_cards(cards) self.assertEqual(deck.remove_cards(1), [two]) self.assertEqual(deck.cards, [ace])
def test_to_remove_number_of_cards_from_deck(self): deck = Deck() ace = Card(rank="Ace", suite="spades") eight = Card(rank="8", suite="diamonds") cards = [ace, eight] deck.add_cards(cards) self.assertEqual(deck.remove_cards(1), [ace]) self.assertEqual(deck.cards, [eight])
public cards. """ wins = 0 for _ in range(EXPECTED_VALUE_SIMULATIONS): deck.shuffle() public_cards = deck.peek(5) full_hand_0 = Hand(private_hand_0.cards + public_cards) full_hand_1 = Hand(private_hand_1.cards + public_cards) if full_hand_0 > full_hand_1: wins += 1 elif full_hand_0 == full_hand_1: wins += 0.5 return wins / EXPECTED_VALUE_SIMULATIONS win_probabilities = {} permutations = get_cards_permutations([]) for i, cards_permutation in enumerate(permutations): deck = Deck() deck.remove_cards(cards_permutation) h1 = Hand(cards_permutation[0:2]) h2 = Hand(cards_permutation[2:4]) key = h1.compressed_representation() + "|" + h2.compressed_representation() if not win_probabilities.get(key): win_probabilities[key] = compute_hand_win_probability(deck, h1, h2) if i % 1000 == 0: print(f"{i}/{len(permutations)}") with open(WIN_PROBABILITIES_FILENAME, "w") as f: json.dump(win_probabilities, f)