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


Python Game.run方法代码示例

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


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

示例1: main

# 需要导入模块: from game.game import Game [as 别名]
# 或者: from game.game.Game import run [as 别名]
def main():
    """ Reversi game with human player vs AI player.
    """

    parser = argparse.ArgumentParser()
    parser.add_argument('--timeout', help="Number of seconds the brain is allowed to think before making its move.",
                        type=int, default=20)
    parser.add_argument('--display-moves', help="Whether legal moves should be displayed or not.", action='store_true')
    parser.add_argument('--colour', help="Display the game in 256 colours.", action='store_true')
    parser.add_argument('--player', help="If you want to play against the ai", action='store_true')
    parser.add_argument('--ai', help="If you want the ais to play against each other", action='store_true')

    args = parser.parse_args()

    if args.timeout < 0:
        exit()

    players=[]
    if args.player:
        players = ['player', 'ai']
    if args.ai:
        players = ['ai', 'ai']
    if not players:
        players = ['player', 'ai']

    game = Game(timeout=args.timeout,
                display_moves=args.display_moves,
                colour=args.colour,
                players=players)
    game.run()
开发者ID:simonproctor,项目名称:reversi-ai,代码行数:32,代码来源:reversi.py

示例2: RandomBot

# 需要导入模块: from game.game import Game [as 别名]
# 或者: from game.game.Game import run [as 别名]
num_of_nodes = 10
num_of_games = 1
num_of_players = 2
log_level = "DEBUG"
players = [Player(0, RandomBot(0)), Player(1, BestReinforcingBot(1))]

logger = logging.getLogger("risk")
logger.setLevel(log_level)

start_time = time.time()

for j in range(0, num_of_games):

    board = Setup().setup_board(players, num_of_nodes)
    game = Game(board, players)
    logger.debug("")
    logger.debug(board)

    #draw_board(board)

    winner = game.run()
    game.player_by_id(winner).increase_won()
    logger.info("Game #" + str(j) + " Over. Winner" + str(winner))

logger.info("")
logger.info("---------------------------------")
logger.info("Winners: ")
for player in players:
    logger.info(player)
logger.info(str(time.time() - start_time) +  "seconds")
开发者ID:jerusalemer,项目名称:risk,代码行数:32,代码来源:risk.py

示例3: Game

# 需要导入模块: from game.game import Game [as 别名]
# 或者: from game.game.Game import run [as 别名]
from game.game import Game

if __name__ == '__main__':
    game = Game()
    game.run()
开发者ID:crhowell,项目名称:python-battleship,代码行数:7,代码来源:battleship.py


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