本文整理汇总了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