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


Python Game.restart方法代码示例

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


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

示例1: Main

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import restart [as 别名]
def Main(stdscr):
    args = Arguments(sys.argv)
    mineFieldWidth, mineFieldHeight, numMines, mode = args.parse()
    game = Game(stdscr, mineFieldWidth, mineFieldHeight, numMines)
    game.start() 
    while True:
        event = stdscr.getch()
        my, mx = 0, 0
        if event == curses.KEY_MOUSE:
            _, mx, my, _, bstate = curses.getmouse()
            if bstate & curses.BUTTON1_PRESSED :
                if game.poke(my, mx) == "dead":
                    game.gameLose()
            elif bstate & curses.BUTTON3_PRESSED:
                game.flag(my, mx)
        maxy, maxx = stdscr.getmaxyx()

        if game.checkWin():
            game.gameWin()

        if event == ord("q") or (mx >= maxx - 9 and mx <= maxx - 4 and my == maxy - 2): 
            game.exit() 

        if event == ord("R") or (mx >= 39 and mx <= 47 and my == maxy - 2):   
            game.displayRecord()

        if event == ord("c") or (mx >= 14 and mx <= 21 and my == maxy - 2):   
            game.resume()

        if event == ord("p") or (mx >= 3 and mx <= 9 and my == maxy - 2):   
            game.pause()

        if event == ord("r") or (mx >= 26 and mx <= 34 and my == maxy - 2):   
            game.restart()
开发者ID:duanduan2015,项目名称:Termine,代码行数:36,代码来源:Termine.py

示例2: main

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import restart [as 别名]
def main(agent_type, no_print=False):
    if no_print:
        sys.stdout = open(os.devnull, 'w')
    global MAX_SCORE, LIMITER, GRID_SIZE, AGENT
    game = Game()
    agent = agent_type(name="BasicNet", actions=ACTIONS, features=GRID_SIZE**2,
    # agent = agent_type(actions=ACTIONS, features=GRID_SIZE ** 2,
                       elligibility_trace=True, game_size=GRID_SIZE, forgetting_factor=0.5)
    AGENT = agent
    game.restart()
    MAX_SCORE = Database.get_high_score(agent.name)
    print(str(datetime.datetime.now()) + " Starting up")
    while LIMITER is None or GAMES < LIMITER:
        step(game, agent)
    agent.save()
    return 1
开发者ID:Nixon-,项目名称:Scruffy,代码行数:18,代码来源:AutoTrain.py


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