def main(): global INIT_CHIPS Table.INIT_CHIPS = INIT_CHIPS o = TerminalJustPotCollectionTextualObserver() t = Table([TerminalPlayer, SemiRandomBot, SemiRandomBot]) t.attach_observer(o) t.run_tournament()
def main(): t = Table([SemiRandomBot, SemiRandomBot, SemiRandomBot]) o = TerminalTextualObserver() f = FileTextualObserver() t.attach_observer(o) t.attach_observer(f) t.run_tournament()
def test_bug_case_00(self) -> None: """ Situation: - All in player is winner - Next best player collects rest Total pot = 28 All in player received: 24 :: (24) Next best player received: 28 :: (4) """ table = Table(create_dummy_classes(3)) player_1 = table._players player_2 = table._players.next player_3 = table._players.next.next table._community_cards = [ Card('9', 'Heart', 8), Card('Jack', 'Spade', 10), Card('5', 'Heart', 4), Card('Ace', 'Diamond', 13), Card('10', 'Diamond', 9) ] player_1._basic_player._hand = [ Card('2', 'Spade', 1), Card('Queen', 'Spade', 11) ] player_2._basic_player._hand = [ Card('King', 'Spade', 12), Card('King', 'Diamond', 12) ] player_3._basic_player._hand = [ Card('8', 'Spade', 7), Card('6', 'Spade', 5) ] table._pot = 28 player_1.total_bet = 10 player_1.current_move = Moves.CHECK player_1._basic_player._chips = 71 player_2.total_bet = 8 player_2.current_move = Moves.ALL_IN player_2._basic_player._chips = 0 player_3.total_bet = 10 player_3.current_move = Moves.CHECK player_3._basic_player._chips = 51 table._init_showdown_phase() table._init_pot_collection_phase() self.assertEqual(75, player_1.get_amount_of_chips()) self.assertEqual(24, player_2.get_amount_of_chips()) self.assertEqual(51, player_3.get_amount_of_chips())
def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs) self.table = Table(create_dummy_classes(4)) self.player_1 = self.table._players self.player_2 = self.player_1.next self.player_3 = self.player_2.next self.player_4 = self.player_3.next self.moves = Moves
def main() -> None: global VALIDATION_EPISODES, INIT_CHIPS, SMALL_BET, BIG_BET Table.INIT_CHIPS = INIT_CHIPS Table.SMALL_BET = SMALL_BET Table.BIG_BET = BIG_BET prepare_dqn() table = Table(PLAYERS) total_win_cnt = {player_name: 0 for player_name in table.player_names} for episode in range(1, VALIDATION_EPISODES + 1): table.reset_tournament() table.run_tournament() total_win_cnt[table.get_winner_name()] += 1 print_progress(episode, total_win_cnt) print_results(total_win_cnt)
from game import Table t = Table() t._data = ["_", "O", "X", "_", "O", "X", "_", "O", "X"] print(t.win())
def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs) Table.INIT_CHIPS = 10 self.table = Table(create_dummy_classes(2)) self.player_1 = self.table._players self.player_2 = self.player_1.next
def test_bug_case_01(self) -> None: """ Situation: 4 players. All in player & another not all in player split the pot. Total pot: 14 All in player received: 5 : (4) Not all in player received: 9 : (10) """ # table = Table(create_dummy_classes(4)) table.INIT_CHIPS = 100 player_1 = table._players player_2 = player_1.next player_3 = player_2.next player_4 = player_3.next table._community_cards = [ Card('Queen', 'Spade', 11), Card('10', 'Club', 9), Card('Jack', 'Spade', 10), Card('Jack', 'Diamond', 10), Card('8', 'Spade', 7) ] player_1.receive_cards( [Card('Jack', 'Heart', 10), Card('8', 'Diamond', 7)]) player_2.receive_cards( [Card('4', 'Club', 3), Card('Queen', 'Club', 11)]) player_3.receive_cards( [Card('6', 'Diamond', 5), Card('Ace', 'Spade', 13)]) player_4.receive_cards( [Card('2', 'Heart', 1), Card('Queen', 'Diamond', 11)]) table._pot = 14 player_1.total_bet = 4 player_1.current_move = Moves.FOLD player_1._basic_player._chips = 38 player_2.total_bet = 6 player_2.current_move = Moves.RAISE player_2._basic_player._chips = 164 player_3.total_bet = 2 player_3.current_move = Moves.FOLD player_3._basic_player._chips = 34 player_4.total_bet = 2 player_4.current_move = Moves.ALL_IN player_4._basic_player._chips = 0 table._init_showdown_phase() table._init_pot_collection_phase() self.assertEqual(38, player_1.get_amount_of_chips()) self.assertEqual(174, player_2.get_amount_of_chips()) self.assertEqual(34, player_3.get_amount_of_chips()) self.assertEqual(4, player_4.get_amount_of_chips())