Esempio n. 1
0
 def test_hand_win_ties_uneven_split(self):
     p1 = Player('p1',100)
     p2 = Player('p2', 100)
     p3 = Player('p3', 100)
     p4 = Player('p4', 100)
     p5 = Player('p5', 100)
     p1.hand_value = 12
     p2.hand_value = 11
     p3.hand_value = 12
     p4.hand_value = 11
     p5.hand_value = 12
     players = [p1,p2,p3,p4,p5]
     p1.bid = 31
     p2.bid = 70
     p3.bid = 50
     p4.bid = 70
     p5.bid = 60
     test_board = Board(players, 10)
     test_board.pot = sum([player.bid for player in players])
     test_board.assign_hand_win(players)
     self.assertEqual(test_board.pot, 0)
     for player in players:
         self.assertEqual(player.bid, 0)
         
     for player in players:
         print(player.money,player.name)
         
     self.assertEqual(p1.money, 100+21+31)
     self.assertEqual(p3.money, 100+21+19+50)
     self.assertEqual(p5.money, 100+20+19+20+60)
Esempio n. 2
0
 def test_hand_win_ties(self):
     p1 = Player('p1',100)
     p2 = Player('p2', 100)
     p3 = Player('p3', 100)
     p4 = Player('p4', 100)
     p5 = Player('p5', 100)
     p1.hand_value = 12
     p2.hand_value = 11
     p3.hand_value = 12
     p4.hand_value = 11
     p5.hand_value = 12
     players = [p1,p2,p3,p4,p5]
     p1.bid = 30
     p2.bid = 70
     p3.bid = 50
     p4.bid = 70
     p5.bid = 60
     test_board = Board(players, 10)
     test_board.pot = sum([player.bid for player in players])
     test_board.assign_hand_win(players)
     self.assertEqual(test_board.pot, 0)
     for player in players:
         self.assertEqual(player.bid, 0)
     self.assertEqual(p1.money, 100+60/3+30)
     self.assertEqual(p5.money, 100+60/3+40/2+20/1+60)
     self.assertEqual(p3.money, 100+60/3+40/2+50)
     self.assertEqual(p4.money, 100+10)
Esempio n. 3
0
 def test_hand_win_multiple_winners(self):
     p1 = Player('p1',100)
     p2 = Player('p2', 100)
     p3 = Player('p3', 100)
     p4 = Player('p4', 100)
     p5 = Player('p5', 120)
     p1.hand_value = 10
     p2.hand_value = 8.1
     p3.hand_value = 8.2
     p4.hand_value = 11
     p5.hand_value = 12
     players = [p1,p2,p3,p4,p5]
     p1.bid = 60
     p2.bid = 20
     p3.bid = 40
     p4.bid = 35
     p5.bid = 30
     test_board = Board(players, 10)
     test_board.pot = sum([player.bid for player in players])
     test_board.assign_hand_win(players)
     self.assertEqual(p5.money, 260)
     self.assertEqual(p4.money, 115)
     self.assertEqual(p1.money, 130)
     self.assertEqual(p3.money, 100)
     self.assertEqual(p2.money, 100)
     self.assertEqual(test_board.pot, 0)
     for player in players:
         self.assertEqual(player.bid, 0)
Esempio n. 4
0
 def test_hand_win(self):
     p1 = Player('p1',100)
     p2 = Player('p2', 100)
     p3 = Player('p3', 100)
     p4 = Player('p4', 100)
     p5 = Player('p5', 100)
     p1.hand_value = 10
     p2.hand_value = 8.1
     p3.hand_value = 8.2
     p4.hand_value = 11
     p5.hand_value = 12
     players = [p1,p2,p3,p4,p5]
     for player in players:
         player.bid = 10
     test_board = Board(players, 10)
     test_board.pot = 50
     test_board.assign_hand_win(players)
     self.assertEqual(p5.money, 150)
     self.assertEqual(test_board.pot, 0)
     for player in test_board.players:
         self.assertEqual(player.bid, 0)
Esempio n. 5
0
 def test_hand_win_first_player_not_highest_bid(self):
     p1 = Player('p1',100)
     p2 = Player('p2', 100)
     p3 = Player('p3', 100)
     p4 = Player('p4', 100)
     p5 = Player('p5', 100)
     p1.hand_value = 10
     p2.hand_value = 8.1
     p3.hand_value = 8.2
     p4.hand_value = 11
     p5.hand_value = 12
     players = [p1,p2,p3,p4,p5]
     for player in players[:4]:
         player.bid = 10
     p5.bid = 5
     for player in players:
         player_is_in_hand = True
     test_board = Board(players, 10)
     test_board.pot = 45
     test_board.assign_hand_win(players)
     self.assertEqual(p5.money, 125)
     self.assertEqual(test_board.pot, 0)
     for player in test_board.players:
         self.assertEqual(player.bid, 0)
Esempio n. 6
0
board.deduct_blinds()
print_out_board('Blinds are added to pot')
board.deal_cards()
print_out_board("cards are dealt")
board.betting_round()
if enough_players():
    print_out_board("Players bet")
    board.add_flop()
    print(board.players)
    if len(board.players) == 2:
        board.players = [board.players[1],board.players[0]]
        print(board.players)
    print_out_board('Flop')
    board.betting_round()
    print_out_board('Post flop betting results')
    if enough_players():
        board.add_river()
        print_out_board('River')
        board.betting_round()
        print_out_board('Post river betting results')
        if enough_players():
            board.add_turn()
            print_out_board('Turn')
            board.betting_round()
            print_out_board('Post turn betting results')
            if enough_players():
                for player in board.players_in_hand():
                    player.hand_value, best_hand = hand_evaluator.find_best_hand(player.cards, board.community_cards)
                    print(player.name,[card.get_properties() for card in best_hand],player.hand_value)
                board.assign_hand_win(board.players_in_hand())
                print_out_board('Money assigned')