本文整理汇总了Python中hand.Hand.value方法的典型用法代码示例。如果您正苦于以下问题:Python Hand.value方法的具体用法?Python Hand.value怎么用?Python Hand.value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hand.Hand
的用法示例。
在下文中一共展示了Hand.value方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Player
# 需要导入模块: from hand import Hand [as 别名]
# 或者: from hand.Hand import value [as 别名]
class Player():
def __init__(self, name, bankroll):
self.hand = Hand()
self.bankroll = bankroll
self.name = name
self.bet = 0
def play_hand(self, dealer_card):
while True:
recommend = basic_strategy(self.hand.value(), dealer_card.value(), self.hand.is_soft())
if len(self.hand.cards) == 2:
move = raw_input("%s: %s - hit/stand/double? (we recommend %s) " % (self.name, self.hand, recommend)).lower()
else:
# for simplicity. This is not true for soft 18.
if recommend == 'double':
recommend = 'hit'
move = raw_input("%s: %s - hit/stand? (we recommend %s) " % (self.name, self.hand, recommend)).lower()
if move.startswith('h'):
return 'hit'
elif move.startswith('s'):
return 'stand'
elif move.startswith('d'):
return 'double'
print "Invalid move"
def __str__(self):
return '(%s, $%s)' % (self.name, self.bankroll)
def is_bust(self):
return self.hand.value() > 21
示例2: Dealer
# 需要导入模块: from hand import Hand [as 别名]
# 或者: from hand.Hand import value [as 别名]
class Dealer(Player):
def __init__(self):
self.hand = Hand()
self.name = "Dealer"
self.bet = 0
self.bankroll = 1e7
def play_hand(self):
if self.hand.value() < 17:
return 'hit'
return 'stand'
def __str__(self):
return "Dealer"