-
Notifications
You must be signed in to change notification settings - Fork 0
/
p_simulator.py
69 lines (62 loc) · 2.2 KB
/
p_simulator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
'''
Created on Apr 8, 2015
Simulates AI and game state of Texas Hold' Em
@author: John Deyrup
'''
# from random import shuffle
# from operator import attrgetter
# from collections import Counter
from player import Player
from board import Board
import hand_evaluator
from card import Card
from operator import attrgetter
def print_out_board(description):
print(description)
for card in board.community_cards:
print(card.get_properties())
for player in board.players:
print(player.get_stats())
print("Pot:", board.pot)
def enough_players():
if len(board.players_in_hand()) > 1:
return True
#Create group of players
player_one = Player('P1', 100)
player_two = Player('P2', 100)
#Creates your board, with players and a starting blind size
board = Board([player_one, player_two], 10)
print_out_board('Players added to board')
board.players_join_round()
print_out_board('Players join round')
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')