Exemplo n.º 1
0
 def __update_community(self):
     # card increment based on which round we are in
     if self.turn_nb == 0:
         pass
     elif self.turn_nb == 1:
         self.community_cards += Card.int_to_str(self.deck.draw(3))
     elif self.turn_nb == 2:
         self.community_cards += [Card.int_to_str(self.deck.draw(1))]
     elif self.turn_nb == 3:
         self.community_cards += [Card.int_to_str(self.deck.draw(1))]
     elif self.turn_nb > 3:
         return
Exemplo n.º 2
0
    def __next_round(self):

        # reinitializing/updating round data

        self.players_info = [
            player.get_player_data() for player in self.players
        ]
        self.round_logger = []

        self.dealer += 1
        self.turn_nb = 0
        self.dealer %= self.n_players

        # distributing cards to players still in
        self.deck = Deck()
        self.community_cards = []

        print('Starting round %d with players %s' %
              (self.round_nb,
               str([
                   i for i, player in enumerate(self.players)
                   if player.game_status == 'in'
               ])))

        for player in self.players:
            if player.game_status == 'in':
                player.new_round(hand=Card.int_to_str(self.deck.draw(2)),
                                 blind=self.blind)

        # running the 4 betting turns
        for _ in range(4):
            self.__next_turn()

        self.display()

        # attributing the gains
        pots = self.__create_pots()
        ranking = self.__rank_players()
        self.__distribute_pots(pots, ranking)

        for player in self.players:
            if player.stack <= 0 and player.game_status != 'out':
                player.game_status = 'out'
                player.round_status = 'out'

        # logging
        self.game_logger += [self.__get_round_info()]
        self.game_logger[-1]['round_history'] = self.round_logger

        self.game_logger[-1]["winner"] = np.where(ranking == 0)[0].tolist()
        self.display()