本文整理汇总了Python中pychess.Utils.GameModel.GameModel.setPlayers方法的典型用法代码示例。如果您正苦于以下问题:Python GameModel.setPlayers方法的具体用法?Python GameModel.setPlayers怎么用?Python GameModel.setPlayers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pychess.Utils.GameModel.GameModel
的用法示例。
在下文中一共展示了GameModel.setPlayers方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start
# 需要导入模块: from pychess.Utils.GameModel import GameModel [as 别名]
# 或者: from pychess.Utils.GameModel.GameModel import setPlayers [as 别名]
def start(discoverer):
atexit.register(SubProcess.finishAllSubprocesses)
pgnfile, gameno = queryGameno(sys.argv[1])
analyzer = queryAnalyzer(discoverer.getAnalyzers())
secs = queryTime()
name1, name2 = pgnfile.get_player_names(gameno)
print("%s will now analyze the game between %s and %s with %d seconds per move." % \
(discoverer.getName(analyzer), name1, name2, secs))
print()
global game, values
values = {}
game = GameModel()
game.setPlayers([DummyPlayer(), DummyPlayer()])
analyzer = discoverer.initAnalyzerEngine(analyzer, ANALYZING, game.variant)
analyzer.connect('analyze', onAnalyze)
game.spectators[HINT] = analyzer
game.loadAndStart(sys.argv[1], pgn, gameno, -1)
def cb():
if game.ply == game.lowply:
on_finish()
return False
check_blund()
return True
glib.timeout_add_seconds(secs, cb)
示例2: do
# 需要导入模块: from pychess.Utils.GameModel import GameModel [as 别名]
# 或者: from pychess.Utils.GameModel.GameModel import setPlayers [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()
示例3: runGame
# 需要导入模块: from pychess.Utils.GameModel import GameModel [as 别名]
# 或者: from pychess.Utils.GameModel.GameModel import setPlayers [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()
示例4: setPlayers
# 需要导入模块: from pychess.Utils.GameModel import GameModel [as 别名]
# 或者: from pychess.Utils.GameModel.GameModel import setPlayers [as 别名]
def setPlayers (self, players):
GameModel.setPlayers(self, players)
if self.players[WHITE].icrating:
self.tags["WhiteElo"] = self.players[WHITE].icrating
if self.players[BLACK].icrating:
self.tags["BlackElo"] = self.players[BLACK].icrating
示例5: CECPTests
# 需要导入模块: from pychess.Utils.GameModel import GameModel [as 别名]
# 或者: from pychess.Utils.GameModel.GameModel import setPlayers [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))
示例6: setPlayers
# 需要导入模块: from pychess.Utils.GameModel import GameModel [as 别名]
# 或者: from pychess.Utils.GameModel.GameModel import setPlayers [as 别名]
def setPlayers (self, players):
if [player.__type__ for player in players] == [REMOTE, REMOTE]:
self.inControl = False
GameModel.setPlayers(self, players)