本文整理汇总了Python中Deck.Deck.reset方法的典型用法代码示例。如果您正苦于以下问题:Python Deck.reset方法的具体用法?Python Deck.reset怎么用?Python Deck.reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Deck.Deck
的用法示例。
在下文中一共展示了Deck.reset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from Deck import Deck [as 别名]
# 或者: from Deck.Deck import reset [as 别名]
#.........这里部分代码省略.........
elif cpu.is_checked() and current_bet == 0:
print "%s checks." % str(cpu)
#there was a raise
elif cpu_bet > current_bet:
print "%s raises to %d." % (str(cpu), cpu_bet)
table.add_bet(cpu_bet)
current_bet = cpu_bet
elif cpu_bet == current_bet:
print "%s matches the bet." % str(cpu)
table.add_bet(cpu_bet)
else:
raise RuntimeError("Problem Occured, exiting")
exit(0)
print "\nCurrent Pot: %d" % table.get_value()
#end for
if non_folded_cpu == []:
break
#####ADD CONDITION TO EXIT OUT OF BETTING LOOP
for cpu in non_folded_cpu:
if cpu.get_last_bet() < current_bet:
ready_to_exit = False
if player.get_last_bet() < current_bet:
ready_to_exit = False
print "Current Bet : %d" % current_bet
elif player.get_last_bet() > current_bet:
raise RuntimeError("Error occured, player bet greater than current bet, should be the same or lesser in value")
exit(0)
if ready_to_exit:
break
####END BET LOOP####
if turn != 3:
table.burn(deck.draw())
table.push(deck.draw())
if non_folded_cpu != []:
map(lambda cpu: cpu.normalize(), non_folded_cpu)
turn += 1
# Calculating who won
player_hand_ranking = table.find_greatest_value(player.get_hand())
print "You had a: %s" % table.get_hand_ranking(player_hand_ranking)
#cpu_has_highest_hand = False implement later
#highest_hand = None
try:
for cpu in non_folded_cpu:
cpu_hand_ranking = table.find_greatest_value(cpu.get_hand())
if cpu_hand_ranking > player_hand_ranking:
print "You lost this round, %s had a \n%s." % (str(cpu), table.get_hand_ranking(cpu_hand_ranking))
table.distribute_winnings_to(cpu)
won_round = False
break # remove later
#Now need to calculate who won based on high card of the hand
elif cpu_hand_ranking == player_hand_ranking:
#Even though both the player and a cpu have the same ranking hand
#The winner can be determined based on the numerical value of the hand
if player.get_hand().calculate_value() > cpu.get_hand().calculate_value():
won_round = True
#If the numerical value and rank are identical
elif player.get_hand().calculate_value() == cpu.get_hand().calculate_value():
print "You both had the same ranked hand. Pot is split"
table.distribute_winnings_to(cpu, player)
won_round = False
break
else:
print "You lost this round, %s had a \n%s." % (str(cpu), table.get_hand_ranking(cpu_hand_ranking))
table.distribute_winnings_to(cpu)
won_round = False
break # remove later
#In the case that all cpu's folded
except IndexError:
pass
if won_round:
print "Congrats, you had the strongest hand this round you won $%d worth of chips!" % table.get_value()
table.distribute_winnings_to(player)
playing = parse_input("Play again? (Y/N)")
deck.reset()
player.get_hand().clear()
table.clear()
#remove any cpu's that are out of chips and can no longer play
for cpu in cpu_players:
cpu.get_hand().clear()
cpu.normalize() # reset certain instance variables to reflect new round
if not cpu.can_play():
print "%s is out of chips and has left the game" % str(cpu)
cpu_players.remove(cpu)
if cpu_players == []:
print "You've eliminated all the other opponents"
playing = False
continue
if PLAY_WITH_BLINDS:
table.inc_blinds(round)
print "\n\n\n\n\n\n\n\n\n\n\n%s" % ("*"*50)
round +=1