当前位置: 首页>>代码示例>>Python>>正文


Python GameState.setup方法代码示例

本文整理汇总了Python中GameState.GameState.setup方法的典型用法代码示例。如果您正苦于以下问题:Python GameState.setup方法的具体用法?Python GameState.setup怎么用?Python GameState.setup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GameState.GameState的用法示例。


在下文中一共展示了GameState.setup方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: play

# 需要导入模块: from GameState import GameState [as 别名]
# 或者: from GameState.GameState import setup [as 别名]
def play(cards, initialDeck, players):
    gs = GameState.setup(cards, initialDeck, players)
    numPlayers = len(gs.players);
    numDepleted = 0
    #print "----------Game Starting--------------------"
    #print numPlayers, 'players:', players
    #print 'Starting deck:', str(initialDeck)
    #print 'Stacks:', str(cards), '\n'
    gameLength = 0
    while (gs.stacks[Province.Province()] != 0) and numDepleted < 3:
        gameLength += 1
        curPlayer = gs.players[gs.turn]
        gs.abcs[gs.turn] = {'actions':1, 'buys':1, 'coins':0}
        import os
        os.system("clear")
        #print("----------Player{0}'s turn--------------------".format(gs.turn))
        #print 'Your deck:\t' + str(gs.pcards[gs.turn].deck)
        #print 'Your discard:\t' + str(gs.pcards[gs.turn].discard)
        #print 'Your hand:\t' + str(gs.pcards[gs.turn].hand)
        
        #print("----------Player{0}'s action phase------------".format(gs.turn))
        gs = curPlayer.playActionPhase(gs)
        #print("----------Player{0}'s buy phase ({1} coins, {2} buys)----".format(gs.turn, gs.abcs[gs.turn]['coins'] + curPlayer.totalTreasure(gs), gs.abcs[gs.turn]['buys']))
        print str(gs.abcs[gs.turn]['coins'] + curPlayer.totalTreasure(gs)) + '\t' + str(gs.abcs[gs.turn]['buys']) + '\t[' + str(gs.players[0].goalDeck - gs.pcards[0].allCards()) + ']'
        bought = gs.stacks.copy()
        gs = curPlayer.playBuyPhase(gs)
        #print("----------Player{0}'s has bought: ({1})----".format(gs.turn, str(bought - gs.stacks)))
        gs = curPlayer.playDiscardPhase(gs)
        gs.turn = (gs.turn + 1) % numPlayers
        numDepleted = len(filter(lambda c: gs.stacks[c] == 0, cards))
        #print("----------Player{0}'s turn has ended----------".format(gs.turn))
        #print("----------------------------------------------\n")
    print "Game Over ({0} turns): ".format(gameLength)
    print 'depleted piles: ', numDepleted
    print 'remaining provinces: ', gs.stacks[Province.Province()]
    print 'stacks:',str(gs.stacks)
    print 'goal deck:', str(gs.players[0].goalDeck)
    print 'mini deck:', str(gs.players[0].miniDeck)
    print 'all player cards:',str(gs.pcards[0].allCards())
开发者ID:drgnrave,项目名称:Dominion-Planner,代码行数:41,代码来源:Runner.py


注:本文中的GameState.GameState.setup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。