Ejemplo n.º 1
0
def evaluate_all_five_card_hands():
    for a in range(48):
        for b in range(a + 1, 49):
            for c in range(b + 1, 50):
                for d in range(c + 1, 51):
                    for e in range(d + 1, 52):
                        evaluate_cards(a, b, c, d, e)
Ejemplo n.º 2
0
def example3():
    print('Example 3: An Omaha poker example')

    p1 = evaluate_cards(
        '4c',
        '5c',
        '6c',
        '7s',
        '8s',  # community cards
        '2c',
        '9c',
        'As',
        'Kd')  # player hole cards

    p2 = evaluate_cards(
        '4c',
        '5c',
        '6c',
        '7s',
        '8s',  # community cards
        '6s',
        '9s',
        'Ts',
        'Js')  # player hole cards

    print(f'The rank of the hand in player 1 is {p1}')  # expected 1578
    print(f'The rank of the hand in player 2 is {p2}')  # expected 1604
    print('Player 1 has a stronger hand')
Ejemplo n.º 3
0
    def test_omaha_example(self):
        p1 = evaluate_cards(
            '4c',
            '5c',
            '6c',
            '7s',
            '8s',  # community cards
            '2c',
            '9c',
            'As',
            'Kd')  # player hole cards

        p2 = evaluate_cards(
            '4c',
            '5c',
            '6c',
            '7s',
            '8s',  # community cards
            '6s',
            '9s',
            'Ts',
            'Js')  # player hole cards

        self.assertEqual(p1, 1578)
        self.assertEqual(p2, 1604)
Ejemplo n.º 4
0
    def test_example(self):
        p1 = evaluate_cards('9c', '4c', '4s', '9d', '4h', 'Qc', '6c')
        p2 = evaluate_cards('9c', '4c', '4s', '9d', '4h', '2c', '9h')

        self.assertEqual(p1, 292)
        self.assertEqual(p2, 236)
        self.assertLess(p2, p1)
Ejemplo n.º 5
0
def evaluate_all_six_card_hands():
    for a in range(47):
        for b in range(a + 1, 48):
            for c in range(b + 1, 49):
                for d in range(c + 1, 50):
                    for e in range(d + 1, 51):
                        for f in range(e + 1, 52):
                            evaluate_cards(a, b, c, d, e, f)
Ejemplo n.º 6
0
def example2():
    p1 = evaluate_cards('9c', '4c', '4s', '9d', '4h', 'Qc',
                        '6c')  # expected 292
    p2 = evaluate_cards('9c', '4c', '4s', '9d', '4h', '2c',
                        '9h')  # expected 236

    print(f'The rank of the hand in player 1 is {p1}')
    print(f'The rank of the hand in player 2 is {p2}')
    print('Player 2 has a stronger hand')
Ejemplo n.º 7
0
def evaluate_all_eight_card_hands():
    for a in range(45):
        for b in range(a + 1, 46):
            for c in range(b + 1, 47):
                for d in range(c + 1, 48):
                    for e in range(d + 1, 49):
                        for f in range(e + 1, 50):
                            for g in range(f + 1, 51):
                                for h in range(g + 1, 52):
                                    evaluate_cards(a, b, c, d, e, f, g, h)
Ejemplo n.º 8
0
def example1():
    a = 7 * 4 + 0  # 9c
    b = 2 * 4 + 0  # 4c
    c = 2 * 4 + 3  # 4s
    d = 7 * 4 + 1  # 9d
    e = 2 * 4 + 2  # 4h

    # Player 1
    f = 10 * 4 + 0  # Qc
    g = 4 * 4 + 0  # 6c

    # Player 2
    h = 0 * 4 + 0  # 2c
    i = 7 * 4 + 2  # 9h

    p1 = evaluate_cards(a, b, c, d, e, f, g)  # expected 292
    p2 = evaluate_cards(a, b, c, d, e, h, i)  # expected 236

    print(f'The rank of the hand in player 1 is {p1}')
    print(f'The rank of the hand in player 2 is {p2}')
    print('Player 2 has a stronger hand')
Ejemplo n.º 9
0
 def test_7cards(self):
     with open(CARDS_FILE_7, 'r') as read_file:
         hand_dict = json.load(read_file)
         for key, value in hand_dict.items():
             self.assertEqual(evaluate_cards(*key.split()), value)