コード例 #1
0
ファイル: run.py プロジェクト: ntemp/poker
def main():
    """ Parses command line arguments and run the poker module """
    parser = argparse.ArgumentParser(
        description='Determine winning poker hand.')
    parser.add_argument('hand_a',
                        metavar='HAND_A',
                        help="the first player's hand")
    parser.add_argument('hand_b',
                        metavar='HAND_B',
                        help="the second player's hand")

    args = parser.parse_args()
    hand_a = Hand(args.hand_a)
    hand_b = Hand(args.hand_b)
    result = compare_hands(hand_a, hand_b)
    print('{}, {}, {}'.format(hand_a.hand_type.name, hand_b.hand_type.name,
                              result))
コード例 #2
0
ファイル: test_poker.py プロジェクト: csatyajith/niw_a_nips
def init_hand():
    n_players = 5
    table = Table(n_players)
    player1, player2, player3, player4, player5 = (Player(500) for _ in range(n_players))
    player1.sit(table, 100)
    player2.sit(table, 100)
    player3.sit(table, 100)
    player4.sit(table, 100)
    player5.sit(table, 100)

    hand = Hand(table)
    return hand
コード例 #3
0
def test_hand_type_four_of_a_kind_1():
    hand = Hand("3C 3H 3S 3D 2H")
    assert hand.hand_type == 7
コード例 #4
0
def test_hand_type_two_pair_1():
    hand = Hand("3C 3H 4S 4D AH")
    assert hand.hand_type == 2
コード例 #5
0
def test_hand_type_full_house_1():
    hand = Hand("3C 3H 3S 2D 2H")
    assert hand.hand_type == 6
コード例 #6
0
def test_hand_pair_5():
    hand = Hand("2C 3H 3S 2D AH")
    assert hand.rank_list == [3, 3, 2, 2, 14]
コード例 #7
0
def test_hand_type_three_1():
    hand = Hand("3C 3H 3S 2D AH")
    assert hand.hand_type == 3
コード例 #8
0
def test_hand_type_royal_flush_1():
    hand = Hand("10H JH QH KH AH")
    assert hand.hand_type == 9
コード例 #9
0
def test_hand_type_flush_1():
    hand = Hand("3C 5C 8C 9C AC")
    assert hand.hand_type == 5
コード例 #10
0
def test_hand_pair():
    hand = Hand("2C 3H 4S JD JH")
    assert hand.hand_type == 1
コード例 #11
0
def test_type(hand, expected):
    assert expected == Hand(hand).hand_type
コード例 #12
0
def test_hand():
    hand = Hand("2C 3H 4S JD KH")
    assert hand.highest_card.str_card == "KH"
コード例 #13
0
def test_sorted_ranks():
    hand = Hand("2C 3H 4S JD KH")
    assert hand.rank_list == [13, 11, 4, 3, 2]
コード例 #14
0
def test_hand_sorting():
    hand = Hand("2C 3H 4S KH JD")
    assert hand.card_list[0].str_card == "KH"
コード例 #15
0
def test_hand_same_suit_2():
    hand = Hand("3H 4H 5H 6H 7D")
    assert hand.same_suit == False
コード例 #16
0
def test_hand_same_suit():
    hand = Hand("3H 4H 5H 6H 7H")
    assert hand.same_suit == True
コード例 #17
0
def test_hand_type_straight_1():
    hand = Hand("3C 4H 5S 6D 7H")
    assert hand.hand_type == 4
コード例 #18
0
def test_raises_on_invalid_hand(hand):
    with pytest.raises(InvalidHand):
        Hand(hand)
コード例 #19
0
def test_hand_type_highest_card_1():
    hand = Hand("2C 3H 4S JD KH")
    assert hand.hand_type == 0
コード例 #20
0
def test_hand_type_straight_flush_1():
    hand = Hand("3H 4H 5H 6H 7H")
    assert hand.hand_type == 8
コード例 #21
0
def test_rank(hand, expected):
    assert expected == Hand(hand).rank
コード例 #22
0
def test_hand_pair_3():
    hand = Hand("2C 3H JS JD JH")
    assert hand.hand_type != 1  # triple?
コード例 #23
0
def test_compare_hand(hand_a, hand_b, expected):
    assert expected == compare_hands(Hand(hand_a), Hand(hand_b))
コード例 #24
0
def test_hand_pair_4():
    hand = Hand("2C 3H 4S 2D AH")
    assert hand.rank_list == [2, 2, 14, 4, 3]