当前位置: 首页>>代码示例>>Python>>正文


Python Evaluator.get_best方法代码示例

本文整理汇总了Python中evaluator.Evaluator.get_best方法的典型用法代码示例。如果您正苦于以下问题:Python Evaluator.get_best方法的具体用法?Python Evaluator.get_best怎么用?Python Evaluator.get_best使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在evaluator.Evaluator的用法示例。


在下文中一共展示了Evaluator.get_best方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from evaluator import Evaluator [as 别名]
# 或者: from evaluator.Evaluator import get_best [as 别名]

#.........这里部分代码省略.........
            else:
                self.common_cards.append(self.deck.get_card())

            self.current_cycle += 1

            # Sets current player to first active player left of the big blind.
            self.current_player = \
                self._get_next_active_player(
                    self._get_next_player(self.dealer, 2))
            self.last_raise = self.current_player

    def _end_round(self, winner=None):
        """Called when the current round ends - either when all players
        but one fold, or when the last betting cycle is completed. When
        an argument is passed, the round is assumed to have ended because
        all players but the one with the index passed have folded.
        Determines a winner in the showdown (if applicable) and gives the
        pot to the winner.
        """
        # Find and save best hand for active each player, while keeping
        # track of the overall best hand

        best_rank = 7463  # Worst possible actual rank is 7462
        best_string = ''  # i.e. 'Full House' or 'Pair of Eights', etc.
        best_cards = []  # Cards comprising the winning hand.
        Tie = False

        if winner is None:
            for index, player in enumerate(self.players_list):
                if player.active or player.all_in:
                    seven_cards = []
                    seven_cards.extend(self.common_cards)
                    seven_cards.extend(player.hand)
                    rank, string, cards = self.evaluator.get_best(seven_cards)
                    if rank < best_rank:
                        if Tie:
                            Tie = False
                        winner = index
                        winners_tie = [winner]
                        best_rank = rank
                        best_string = string
                        best_cards = cards
                    elif rank == best_rank:
                        Tie = True
                        winners_tie.append(index)

        if Tie:
            split_pot = self.pot // len(winners_tie)
            for player_index in winners_tie:
                self.players_list[player_index].points += split_pot

        # If the winner was all in, they cannot win more than the pot amount
        # at the time of going all in.
        elif self.players_list[winner].all_in:
            subpot = self._calculate_subpot(self.players_list[winner].bet)
            self.players_list[winner].points += subpot
            self.pot -= subpot
            self.players_list[winner].all_in = False
            if self.pot > 0:
                self._end_round()  # Find winner of remaining pot

        else:
            self.players_list[winner].points += self.pot

        #  For testing by running from command line.
        self.done = True
开发者ID:risingmoon,项目名称:online-card-game,代码行数:70,代码来源:game.py


注:本文中的evaluator.Evaluator.get_best方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。