本文整理汇总了Python中Deck.printCards方法的典型用法代码示例。如果您正苦于以下问题:Python Deck.printCards方法的具体用法?Python Deck.printCards怎么用?Python Deck.printCards使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Deck
的用法示例。
在下文中一共展示了Deck.printCards方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Game
# 需要导入模块: import Deck [as 别名]
# 或者: from Deck import printCards [as 别名]
class Game():
def __init__(self, numPlayers, maxSimulationDepth):
self._players = []
self._currentPlayerIndex = 0
self._deck = Deck()
self._cardDrawManager = CardDrawManager(self)
print "==========="
self._deck.printCards()
for playerIndex in range(numPlayers):
player = Player(self, playerIndex)
self._players.append(player)
for drawIndex in range(InitialDrawCount):
self._cardDrawManager.handleDrawFor(player)
for player in self._players:
print player
print "============="
self._progress = {}
for suit in SUITS:
self._progress[suit] = 0
self._hintTokens = InitialHintTokens
self._deathTokens = InitialDeathTokens
self._maxSimulationDepth = maxSimulationDepth
def deck(self):
return self._deck
def currentPlayerIndex(self):
return self._currentPlayerIndex
def iteratePlayerIndex(self):
self._currentPlayerIndex += 1
self._currentPlayerIndex %= len(self._players)
def play(self):
while self._deck.hasNext() and self._deathTokens > 0:
self.doTurn()
for i in range(len(self._players)):
if self._deathTokens == 0:
break
self.doTurn()
if self._deathTokens == 0:
print "Ended early because we fucked up."
print self._progress
def doTurn(self):
simulation = Simulation(self, self._players[self._currentPlayerIndex])
self.simulateSingleTurn(simulation)
self.iteratePlayerIndex()
def simulateSingleTurn(self, simulation):
canPrint = simulation._depth == 0
action, score = self._players[self._currentPlayerIndex].getActionForTurn(simulation)
if canPrint:
print "--------"
print str.format("{} will do: {}. Score at depth: {}", self.currentPlayer(), action, score)
self.printProgress()
self.processAction(action, simulation.isSimulating())
if canPrint:
print str.format("Score after play: {}. Hint tokens: {}. Death Tokens: {}", self.score(None), self._hintTokens, self._deathTokens)
print "--------"
return score # Represents the best score at the deepest sim level.
def processAction(self, action, isSimulating):
if action.actionName() == "Hint":
self.processHint(action)
else:
self.processBurnOrPlay(action, isSimulating)
def processHint(self, hint):
hint.player().receiveHint(hint)
self._hintTokens -= 1
def processBurnOrPlay(self, action, isSimulating):
player = action.player()
cardFact = action.cardFact()
player.dropCard(cardFact)
if action.actionName() == "Burn":
self._hintTokens += 1
else: # Play:
card = cardFact.card()
suit = card.suit()
number = card.number()
if self.progress(suit) == number - 1:
self._progress[suit] = number # :)
else:
self._deathTokens -= 1 # :(
if not isSimulating:
self._cardDrawManager.handleDrawFor(player)
#.........这里部分代码省略.........