本文整理汇总了Python中card.Card.int_to_pretty_str方法的典型用法代码示例。如果您正苦于以下问题:Python Card.int_to_pretty_str方法的具体用法?Python Card.int_to_pretty_str怎么用?Python Card.int_to_pretty_str使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类card.Card
的用法示例。
在下文中一共展示了Card.int_to_pretty_str方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Evaluator
# 需要导入模块: from card import Card [as 别名]
# 或者: from card.Card import int_to_pretty_str [as 别名]
from evaluator import Evaluator
from card import Card
from util import Util
evaluator = Evaluator()
util = Util()
average_range= set()
for set_ in Util.PAIRS.values():
average_range |= set_
average_range |= (Util.UNSUITED['AK'] | Util.UNSUITED['K8'] |
Util.UNSUITED['AQ'] | Util.UNSUITED['QJ'] |
Util.UNSUITED['AJ'] | Util.UNSUITED['QT'] |
Util.UNSUITED['AT'] |
Util.UNSUITED['A9'] |
Util.UNSUITED['A8'] |
Util.UNSUITED['KQ'] |
Util.UNSUITED['KJ'] |
Util.UNSUITED['T9'])
hole_cards = list(map(Card.new, ['Ah', 'Jd']))
community_cards = list(map(Card.new, ['2c', 'Qh', '9d']))
print("hole_cards ", " ".join(Card.int_to_pretty_str(card) for card in hole_cards))
print("community_cards", " ".join(Card.int_to_pretty_str(card) for card in community_cards))
print("all_cards ", " ".join(Card.int_to_pretty_str(card) for card in hole_cards + community_cards))
score = evaluator.evaluate(hole_cards, community_cards)
print("score", score)
print("rank", evaluator.class_to_string(evaluator.get_rank_class(score)))
print(util.my_equity(tuple(hole_cards), tuple(community_cards), average_range))
示例2: on_new_round
# 需要导入模块: from card import Card [as 别名]
# 或者: from card.Card import int_to_pretty_str [as 别名]
def on_new_round(self, game_view):
"""Called at the beginning of a new round of betting."""
time.sleep(0.2)
community_cards = " ".join([Card.int_to_pretty_str(card) for card in game_view.community_cards])
示例3: on_new_hand
# 需要导入模块: from card import Card [as 别名]
# 或者: from card.Card import int_to_pretty_str [as 别名]
def on_new_hand(self, game_view):
"""Called at the beginning of a new hand."""
hole_cards = " ".join([Card.int_to_pretty_str(card) for card in game_view.hole_cards])
示例4: bet
# 需要导入模块: from card import Card [as 别名]
# 或者: from card.Card import int_to_pretty_str [as 别名]
def bet(self, game_view):
"""
Called when asking how much a player would like to bet.
Returning None folds.
"""
g = game_view
hole_cards = " ".join([Card.int_to_pretty_str(card) for card in g.hole_cards])
community_cards = " ".join([Card.int_to_pretty_str(card) for card in g.community_cards])
print('\n Action to you', self.name)
print(' You have', g.my_chips, 'chips.')
print(' There are', g.pot_size, 'chips in the pot.')
print(' Other players chips:')
opposing_chip_stacks = " -- ".join([str(chips[0]) + ':' + str(chips[1]) for chips in g.chips.items()])
print(' ', opposing_chip_stacks)
if community_cards:
print(' Community cards are:', community_cards)
print(' Your cards are:', hole_cards)
if g.my_chips == 0:
print(" You're all in!")
return min(g.min_bet, g.my_chips)
prompt = " It's {0} to stay in and minimum raise is {1}.\n What would you like to do?\n > ".format(g.min_bet if g.min_bet > 0 else 'free', g.min_raise)
while True:
n = input(prompt).split(' ')
print()
if len(n) == 1:
action = n[0]
else:
action, amount = n
action = action.lower()
if action == 'fold':
return None
if action == 'check':
if g.min_bet == 0:
return 0
else:
print(" You can't check. You must fold or bet at least", min(g.my_chips, g.min_bet))
if action in ('call', 'stay', 'hold'):
return min(g.min_bet, g.my_chips)
if action in ('raise', 'bet'):
if amount == 'all':
return g.my_chips
try:
amount = int(amount)
except:
print(" You must bet an integer number of chips.")
continue
if action == 'raise':
amount += g.min_bet
if amount < g.min_bet and amount < g.my_chips:
print(" You must bet at least", min(g.my_chips, g.min_bet))
continue
if amount > g.min_bet and amount < (g.min_bet + g.min_raise) and amount < g.my_chips:
print(" You must raise by at least", g.min_raise)
continue
if amount > g.my_chips:
print(" You don't have that many chips.")
continue
return int(amount)
if action == 'all':
return g.my_chips
if action in ('quit', 'exit'):
sys.exit()
print(" I don't understand. Try again.")