def test_everyone_agree_logic_regression(self):
        players = [Player("uuid%d" % i, 100) for i in range(4)]
        players[0].stack = 150
        players[1].stack = 150
        players[2].stack = 50
        players[3].stack = 50
        deck = Deck(cheat=True, cheat_card_ids=range(1, 53))
        table = Table(cheat_deck=deck)
        for player in players:
            table.seats.sitdown(player)
        table.dealer_btn = 3
        table.set_blind_pos(0, 1)

        state, _ = RoundManager.start_new_round(1, 5, 0, table)
        state, _ = RoundManager.apply_action(state, "raise", 15)
        state, _ = RoundManager.apply_action(state, "raise", 20)
        state, _ = RoundManager.apply_action(state, "raise", 25)
        state, _ = RoundManager.apply_action(state, "raise", 30)
        state, _ = RoundManager.apply_action(state, "raise", 50)
        state, _ = RoundManager.apply_action(state, "call", 50)
        state, _ = RoundManager.apply_action(state, "raise", 125)
        state, _ = RoundManager.apply_action(state, "call", 125)
        state, _ = RoundManager.apply_action(state, "fold", 0)
        state, _ = RoundManager.apply_action(state, "fold", 0)
        self.eq(Const.Street.FINISHED, state["street"])
Example #2
0
def _restore_table(round_state):
    table = Table()
    table.dealer_btn = round_state["dealer_btn"]
    table.set_blind_pos(round_state["small_blind_pos"], round_state["big_blind_pos"])
    _restore_community_card_on_table(table, round_state["community_card"])
    table.deck = _restore_deck(round_state["community_card"])
    table.seats = _restore_seats(round_state["seats"], round_state["action_histories"])
    return table
Example #3
0
 def __setup_table(self):
     players = [Player("uuid%d" % i, 100) for i in range(3)]
     deck = Deck(cheat=True, cheat_card_ids=range(1, 53))
     table = Table(cheat_deck=deck)
     for player in players: table.seats.sitdown(player)
     table.dealer_btn = 2
     table.set_blind_pos(0, 1)
     return table
Example #4
0
 def __init__(self, small_blind_amount=None, initial_stack=None, ante=None):
     self.small_blind_amount = small_blind_amount
     self.ante = ante if ante else 0
     self.initial_stack = initial_stack
     self.uuid_list = self.__generate_uuid_list()
     self.message_handler = MessageHandler()
     self.message_summarizer = MessageSummarizer(verbose=0)
     self.table = Table()
     self.blind_structure = {}
Example #5
0
 def __setup_players_with_table(self):
     p1 = Player('uuid1', 100)
     p2 = Player('uuid2', 100)
     p3 = Player('uuid3', 100)
     p2.pay_info.update_to_fold()
     p3.pay_info.update_to_allin()
     table = Table()
     for player in [p1, p2, p3]:
         table.seats.sitdown(player)
     return table
def _restore_table(round_state):
    table = Table()
    table.dealer_btn = round_state['dealer_btn']
    table.set_blind_pos(round_state['small_blind_pos'],
                        round_state['big_blind_pos'])
    _restore_community_card_on_table(table, round_state['community_card'])
    table.deck = _restore_deck(round_state['community_card'])
    table.seats = _restore_seats(round_state['seats'],
                                 round_state['action_histories'])
    return table
Example #7
0
 def __init__(self, small_blind_amount=None, initial_stack=None, ante=None, log_file_location: str = ''):
     self.small_blind_amount = small_blind_amount
     self.ante = ante if ante else 0
     self.initial_stack = initial_stack
     self.uuid_list = self.__generate_uuid_list()
     self.message_handler = MessageHandler()
     self.message_summarizer = MessageSummarizer(verbose=0)
     self.table = Table()
     self.blind_structure = {}
     self.log_file_location = log_file_location
     self.game_history = {}
Example #8
0
 def start_game(self, players_info, game_config):
     self.config = game_config
     # setup table
     table = Table()
     for uuid, name in players_info.items():
         player = Player(uuid, game_config['initial_stack'], name)
         table.seats.sitdown(player)
     # start the first round
     state, msgs = self._start_new_round(1, game_config['blind_structure'],
                                         table)
     self.current_state = state
     return _parse_broadcast_destination(msgs, self.current_state['table'])
Example #9
0
    def generate_initial_game_state(self, players_info):
        table = Table()
        for uuid, info in players_info.items():
            table.seats.sitdown(Player(uuid, info["stack"], info["name"]))

        table.dealer_btn = len(table.seats.players) - 1
        return {
            "round_count": 0,
            "small_blind_amount": self.game_rule["sb_amount"],
            "street": Const.Street.PREFLOP,
            "next_player": None,
            "table": table
        }
Example #10
0
def setup_table():
    table = Table()
    players = [Player("uuid%d" % i, 100, "hoge") for i in range(3)]
    table.seats.players = players
    table.add_community_card(Card.from_id(1))
    table.dealer_btn = 2
    table.set_blind_pos(2, 0)
    p1, p2, p3 = table.seats.players
    p3.add_action_history(Const.Action.RAISE, 10, 5)
    p1.add_action_history(Const.Action.FOLD)
    p2.add_action_history(Const.Action.RAISE, 20, 10)
    p3.add_action_history(Const.Action.CALL, 20)
    [
        p.save_street_action_histories(Const.Street.PREFLOP)
        for p in [p1, p2, p3]
    ]
    p3.add_action_history(Const.Action.CALL, 5)
    p2.add_action_history(Const.Action.RAISE, 5, 5)
    return table
 def __setup_table(self):
   table = Table()
   table.set_blind_pos(0, 1)
   table.seats = self.__setup_seats()
   table.add_community_card(Card.from_id(1))
   return table
Example #12
0
 def __init__(self, small_blind_amount=None, initial_stack=None, ante=None):
     super().__init__(self,
                      small_blind_amount=small_blind_amount,
                      initial_stack=initial_stack,
                      ante=ante)
     self.table = Table(cheat_deck=EmptyCheatDeck())
Example #13
0
 def __setup_table(self, players):
     table = Table()
     for player in players:
         table.seats.sitdown(player)
     return table
Example #14
0
 def __setup_table(self):
     self.table = Table()
     for card in self.table.deck.draw_cards(5):
         self.table.add_community_card(card)