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


Python GameModel.start方法代码示例

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


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

示例1: do

# 需要导入模块: from pychess.Utils.GameModel import GameModel [as 别名]
# 或者: from pychess.Utils.GameModel.GameModel import start [as 别名]
def do(discoverer):
    game = GameModel(TimeModel(60,0))
    #game.connect('game_started', cb_gamestarted2)
    game.connect('game_ended', lambda *a: mainloop.quit())
    p0 = discoverer.initPlayerEngine(discoverer.getEngines()['rybka'], WHITE, 7, variants[NORMALCHESS], 60)
    p1 = discoverer.initPlayerEngine(discoverer.getEngines()['gnuchess'], BLACK, 7, variants[NORMALCHESS], 60)
    game.setPlayers([p0,p1])
    game.start()
开发者ID:fowode,项目名称:pychess,代码行数:10,代码来源:arena.py

示例2: runGame

# 需要导入模块: from pychess.Utils.GameModel import GameModel [as 别名]
# 或者: from pychess.Utils.GameModel.GameModel import start [as 别名]
def runGame():
    a, b = findMatch()
    if a == None:
        print("All games have now been played. Here are the final scores:")
        printResults()
        mainloop.quit()
        return
    current[0] = a
    current[1] = b
    
    game = GameModel(TimeModel(minutes*60,0))
    game.connect('game_started', cb_gamestarted)
    game.connect('game_ended', cb_gameended)
    p0 = discoverer.initPlayerEngine(engines[a], WHITE, 8, variants[NORMALCHESS], secs=minutes*60, incr=0, forcePonderOff=True)
    p1 = discoverer.initPlayerEngine(engines[b], BLACK, 8, variants[NORMALCHESS], secs=minutes*60, incr=0, forcePonderOff=True)
    game.setPlayers([p0,p1])
    game.start()
开发者ID:fowode,项目名称:pychess,代码行数:19,代码来源:arena.py

示例3: CECPTests

# 需要导入模块: from pychess.Utils.GameModel import GameModel [as 别名]
# 或者: from pychess.Utils.GameModel.GameModel import start [as 别名]
class CECPTests(unittest.TestCase):
    def setUp(self):
        self.engine = discoverer.getEngineByName("PyChess.py")

    def test(self):
        """ Play PyChess-PyChess 1 min variant games """

        if sys.platform == "win32":
            from asyncio.windows_events import ProactorEventLoop
            loop = ProactorEventLoop()
            asyncio.set_event_loop(loop)
        else:
            loop = asyncio.SelectorEventLoop()
            asyncio.set_event_loop(loop)

        loop = asyncio.get_event_loop()
        loop.set_debug(enabled=True)

        for vari in PYCHESS_VARIANTS:
            variant = variants[vari]

            def coro():
                self.p0 = yield from discoverer.initEngine(self.engine, WHITE, False)
                self.p1 = yield from discoverer.initEngine(self.engine, BLACK, False)

            loop.run_until_complete(coro())

            def optionsCallback(engine):
                engine.setOptionVariant(variant)
                engine.setOptionStrength(1, False)
                engine.setOptionTime(60, 0, 0)

            self.p0.connect("readyForOptions", optionsCallback)
            self.p1.connect("readyForOptions", optionsCallback)

            def coro(variant):
                self.game = GameModel(TimeModel(60, 0), variant)
                self.game.setPlayers([self.p0, self.p1])

                def on_game_end(game, state, event):
                    event.set()

                event = asyncio.Event()
                self.game.connect("game_ended", on_game_end, event)

                self.p0.prestart()
                self.p1.prestart()

                if self.game.variant.need_initial_board:
                    for player in self.game.players:
                        player.setOptionInitialBoard(self.game)

                print(variant.name)
                self.game.start()

                yield from event.wait()

                pgn = StringIO()
                print(save(pgn, self.game))

                self.assertIsNone(self.p0.invalid_move)
                self.assertIsNone(self.p1.invalid_move)

            loop.run_until_complete(coro(variant))
开发者ID:teacoffee2017,项目名称:pychess,代码行数:66,代码来源:selfplay.py


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