本文整理汇总了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()
示例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()
示例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))