本文整理汇总了Python中hand.Hand.insert方法的典型用法代码示例。如果您正苦于以下问题:Python Hand.insert方法的具体用法?Python Hand.insert怎么用?Python Hand.insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hand.Hand
的用法示例。
在下文中一共展示了Hand.insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: play
# 需要导入模块: from hand import Hand [as 别名]
# 或者: from hand.Hand import insert [as 别名]
def play(self):
players = self._players
shoe = self._shoe
#movegen = MoveGenerator(shoe)
while True:
if players:
eliminated_players = []
for player in players:
if not player.can_bet(self._MINIMUM_BET):
eliminated_players.append(player)
players.remove(player)
if eliminated_players:
print '<'*60
print 'Following players cannot bet any further and are removed from table:'
for player in eliminated_players:
print 'Player {0}'.format(player.id)
print '>'*60
pass
else:
#Collect bets from each player
bets = self._collect_bets(players)
#Initialize them a hand for the bet they made
hands = [ [player,Hand(bet)] for player, bet in zip(players, bets) ]
dealer_hand = Hand(0)
print '#'*60
print 'First Card will be served'
print '#'*60
#Serve them their first card
[hand.insert(shoe.draw()) for player,hand in hands]
#Serve the dealer the first card
#TODO When we have limits for dealer, break conditions here
dealer_hand.insert(shoe.draw())
#Print state for each player
for player,hand in hands:
print 'Player {0} : Your Cards are :'.format(player.id)
print hand
print '*'*50
print 'Dealers Hand :'
print dealer_hand
print '*'*50
print '#'*60
print 'Next Card will be served'
print '#'*60
#Serve them their second card
[hand.insert(shoe.draw()) for player,hand in hands]
dealer_hand.insert(shoe.draw())
for player,hand in hands:
print 'Player {0} : Your Cards are :'.format(player.id)
print hand
print '#'*60
final_hands =[]
for player,hand in hands:
for ret_hand in self._user_action(player,hand):
final_hands.append(ret_hand)
#Show Dealer's Hand
print '#'*60
print 'Dealer\s Hand'
print dealer_hand
while True:
dealer_value = dealer_hand.evaluate()
if dealer_value in range(1,17):
self._move_generator._hit(self._dealer,dealer_hand)
else:
break
print '#'*60
print 'Dealer\'s Final Hand'
print dealer_hand
#Print Dealer's state
for player,hand in final_hands:
payoff_code = self._compare(hand,dealer_hand)
value = self._payoff(player, hand, payoff_code)
if payoff_code > 1:
print 'Player {0} had a blackjack. Gets Back {1}'.format(player.id, value)
if payoff_code == 1:
print 'Player {0} had a win. Gets Back {1}'.format(player.id, value)
if payoff_code == 0:
print 'Player {0} had a push. Gets Back {1}'.format(player.id, value)
if payoff_code < 0:
print 'Player {0} had a loss. Loses {1}'.format(player.id, value)
#collect used cards
for card in hand._cards:
self._shoe.collect(card)
#.........这里部分代码省略.........