def test_neverplay(): table = Table() # Dealer will bet first preflop, so 2 will win as for now all players will fold num_players = 3 players = [] for i in xrange(num_players): player = Player(10, 'NeverPlay') player.sit(table, i) players.append(player) assert table.button_seat == -1 table.deal() assert table.button_seat == 0 assert table.players[2].chips == 11 assert table.players[1].chips == 9 assert table.players[0].chips == 10
def test_alwayscall(): table = Table() # Dealer will bet first preflop, so 2 will win as for now all players will fold num_players = 3 players = [] for i in xrange(num_players): player = Player(10, 'AlwaysCall') player.sit(table, i) players.append(player) assert table.button_seat == -1 table.deal() assert table.button_seat == 0 # I don't know who won here chips = [] for player in table.players.values(): chips.append(player.chips) assert (chips.count(8) == 2 and chips.count(14) == 1) or \ (chips.count(8) == 2 and chips.count(14) == 1) or \ (chips.count(10) == 3)
def main(): args = vars(parser.parse_args()) print args # Get from command line: # Type of players # Chips for players numplayers = len(args['players']) if numplayers < 3: print 'At least 3 players are needed. You selected', numplayers return #if args['chips'] is not None and len(args['chips']) > numplayers: #numplayers = len(args['chips']) table = Table() for i in xrange(numplayers): player = Player(int(args['players'][i][0]), args['players'][i][1]) player.sit(table, i) for i in xrange(args['numhands']): table.deal() print 'After', args['numhands'], 'hands:' for player in table.players.values(): print 'Player', player.position, 'has', player.chips, 'chips' print 'The Table has', table.box, 'chips'