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


Python GameState.nextPlayer方法代码示例

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


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

示例1: TerraMystica

# 需要导入模块: from gamestate import GameState [as 别名]
# 或者: from gamestate.GameState import nextPlayer [as 别名]
class TerraMystica(object):
    def __init__(self):
        self.gameState = GameState();
        self.worldMap = worldMap;

    def gameLoop(self, log=False, logToFile=""):
        self.gameState.logComment("\n", False, logToFile);

        while True:
            #Game is over after 6 turns
            if self.gameState.currentTurn >= 6: break;

            results = self.gameState.generateOperations(self.gameState.currentPlayer);
            print "== Turn %s =="%(self.gameState.currentTurn);
            for playerNumber, player in sorted(self.gameState.players.items()): print "%s %s\t%s"%(playerNumber, "**" if self.gameState.currentPlayer == playerNumber else "", player);
            print;
            print UI(self.gameState, (UI.DisplayWorld,[]));

            earlierTurn = self.gameState.currentTurn;
            if self.gameState.players[self.gameState.currentPlayer].isComputer:
                clist = AI(timeout=30.0).calculateBestMove(self.gameState);
                for command in clist:
                    if isinstance(command, list):
                        self.gameState.processCommand(command, log=False, logToFile=logToFile);
                        continue;

                    print;
                    _, clist = UI(self.gameState).navigateCommandMenu(command);
                    for subcommand in clist: self.gameState.processCommand(subcommand, log=False, logToFile=logToFile);
            else:
                _, clist = UI(self.gameState).navigateCommandMenu(results);
                for command in clist: self.gameState.processCommand(command, log=False, logToFile=logToFile);

            self.gameState.logComment("\n", False, outputFile);

            #Hack to ensure we have the correct player action rotations
            if earlierTurn == self.gameState.currentTurn: self.gameState.nextPlayer();

        print "Game Over!";
开发者ID:quilan1,项目名称:TM,代码行数:41,代码来源:terramystica.py


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