本文整理汇总了Python中Deck.Deck.pop方法的典型用法代码示例。如果您正苦于以下问题:Python Deck.pop方法的具体用法?Python Deck.pop怎么用?Python Deck.pop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Deck.Deck
的用法示例。
在下文中一共展示了Deck.pop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Dealer
# 需要导入模块: from Deck import Deck [as 别名]
# 或者: from Deck.Deck import pop [as 别名]
class Dealer(object):
def __init__(self, deck=None, discard_pile=None, payout_table=None):
self.deck = Deck(52)
self.discard_pile = DiscardPile()
def shuffle_deck(self):
temp_deck = Deck(0)
for k in range(len(self.deck)):
temp_deck.append(self.deck.pop(random.randint(0, len(self.deck)-1)))
self.deck = temp_deck
def deal_card(self):
return self.deck.pop(0)
def deal_indexed_card(self, index):
return copy.copy(self.deck[index])
# return self.deck.pop(index))
def rate_hand(self):
pass
def collect_hand(self):
pass
示例2: Hand
# 需要导入模块: from Deck import Deck [as 别名]
# 或者: from Deck.Deck import pop [as 别名]
cards = []
cards.append(Card("K", "H"))
cards.append(Card("K", "D"))
cards.append(Card("4", "S"))
cards.append(Card("4", "C"))
cards.append(Card("10", "H"))
hand4 = Hand(cards)
assert hand4.handType == 3, "Unit Test Failed : Two Pairs"
assert hand3 < hand4, "Unit Test Failed : Two pairs comparison"
# Random testing (todo: oracle)
for i in range(100):
deck = Deck()
deck.shuffle()
cards = []
for c in range(5):
cards.append(deck.pop())
hand1 = Hand(cards)
while len(cards) > 0:
deck.push(cards.pop())
deck.shuffle()
for c in range(5):
cards.append(deck.pop())
hand2 = Hand(cards)
if (hand1.compare(hand2) == 0):
print("1 : ", hand1)
print("2 : ", hand2)
print("1 < 2 : ", hand1.compare(hand2))
print("-----")