本文整理汇总了Python中fysom.Fysom.pause方法的典型用法代码示例。如果您正苦于以下问题:Python Fysom.pause方法的具体用法?Python Fysom.pause怎么用?Python Fysom.pause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fysom.Fysom
的用法示例。
在下文中一共展示了Fysom.pause方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from fysom import Fysom [as 别名]
# 或者: from fysom.Fysom import pause [as 别名]
#.........这里部分代码省略.........
self.search.reset()
self.explore.reset()
self.initialize = Fysom(
{
"initial": "init",
"events": [
{"name": "uci", "src": "init", "dst": "stockfish"},
{"name": "isready", "src": "stockfish", "dst": "uciok"},
{"name": "reset", "src": "uciok", "dst": "init"},
],
"callbacks": {"onstockfish": onstockfish, "onuciok": onuciok},
}
)
self.search = Fysom(
{
"initial": "init",
"events": [
{"name": "newgame", "src": "init", "dst": "godepth"},
{"name": "searching", "src": "godepth", "dst": "godepth"},
{"name": "makemove", "src": "godepth", "dst": "move"},
{"name": "searching", "src": "move", "dst": "godepth"},
{"name": "newgame", "src": "move", "dst": "godepth"},
{"name": "reset", "src": "move", "dst": "init"},
],
"callbacks": {"onnewgame": onnewgame, "onmove": onmove},
}
)
self.explore = Fysom(
{
"initial": "init",
"events": [
{"name": "ucinewgame", "src": "init", "dst": "goinfinite"},
{"name": "infinite", "src": "goinfinite", "dst": "goinfinite"},
{"name": "move", "src": "goinfinite", "dst": "bestmove"},
{"name": "infinite", "src": "bestmove", "dst": "goinfinite"},
{"name": "ucinewgame", "src": "bestmove", "dst": "goinfinite"},
{"name": "mate", "src": "bestmove", "dst": "end"},
{"name": "reset", "src": "bestmove", "dst": "init"},
],
"callbacks": {"onucinewgame": onucinewgame, "onbestmove": onbestmove},
}
)
self.boomerang = Fysom(
{
"initial": "start",
"events": [
{"name": "startsearch", "src": "start", "dst": "godeeper"},
{"name": "restart", "src": "wait", "dst": "start"},
{"name": "exploremove", "src": "godeeper", "dst": "explore"},
{"name": "exploremove", "src": "explore", "dst": "explore"},
{"name": "noMoves", "src": "explore", "dst": "analyze"},
{"name": "pause", "src": "analyze", "dst": "wait"},
],
"callbacks": {"ongodeeper": ongodeeper, "onexplore": onexplore, "onwait": onwait},
}
)
def resetGame(self):
self.gameStatus["startpos"] = "startpos"
self.gameStatus["moves"] = []
self.gameStatus["moveDepths"] = {}
self.gameStatus["fen"] = (True,)
self.gameStatus["centipawns"] = 0
self.gameStatus["currentMove"] = 1
self.gameStatus["startPlayer"] = "w"
self.gameStatus["player"] = "w"
self.gameStatus["JSONlines"] = []
self.gameStatus["JSONcurrentLine"] = {}
self.gameStatus["JSONmoves"] = []
self.gameStatus["JSONcurrentMove"] = {}
def findBoomerang(self, startpos):
self.resetGame()
self.gameStatus["startpos"] = startpos
while True:
if self.boomerang.isstate("start"):
res = self.manager.get()
if re.search("^Stockfish", res):
self.initialize.uci(self.gameStatus)
if re.search("^uciok", res):
self.initialize.isready()
if re.search("^readyok", res):
self.boomerang.startsearch(
self.movesList, self.movesListCP, self.searchingDepth, self.gameStatus, self.cp
)
elif self.boomerang.isstate("wait"):
self.initialize.uci(self.gameStatus)
self.manager.clear()
self.boomerang.restart()
elif self.boomerang.isstate("godeeper"):
self.boomerang.exploremove(
self.movesList, self.movesListCP, self.totalMoves, self.exploreDepth, self.gameStatus
)
elif self.boomerang.isstate("analyze"):
break
self.boomerang.pause()
return json.dumps(self.gameStatus["JSONlines"])
示例2: __init__
# 需要导入模块: from fysom import Fysom [as 别名]
# 或者: from fysom.Fysom import pause [as 别名]
#.........这里部分代码省略.........
onsearch(res, gameStatus)
if re.search('^bestmove (?P<move>\w+) ', res):
bestmove = re.search('^bestmove (?P<move>\w+) ', res)
self.explore.move(bestmove.group('move'), gameStatus, exploreDepth, totalMoves, move)
if (gameStatus["currentMove"]>=totalMoves):
break
currentLine = {}
currentLine["searchingDepth"] = gameStatus["moveDepths"][move]
currentLine["moves"] = gameStatus["JSONmoves"][:]
gameStatus["JSONlines"].append(currentLine)
self.boomerang.noMoves()
def onwait(e):
self.initialize.reset()
self.search.reset()
self.explore.reset()
self.initialize = Fysom({'initial': 'init',
'events': [{'name': 'uci','src':'init','dst':'stockfish'},
{'name': 'isready','src':'stockfish','dst':'uciok'},
{'name': 'reset','src':'uciok','dst':'init'}],
'callbacks': {
'onstockfish': onstockfish,
'onuciok': onuciok } })
self.search = Fysom({'initial': 'init',
'events': [{'name': 'newgame','src':'init','dst':'godepth'},
{'name': 'searching','src':'godepth','dst':'godepth'},
{'name': 'makemove','src':'godepth','dst':'move'},
{'name': 'searching','src':'move','dst':'godepth'},
{'name': 'newgame','src':'move','dst':'godepth'},
{'name': 'reset','src':'move','dst':'init'}],
'callbacks': {
'onnewgame': onnewgame,
'onmove': onmove} })
self.explore = Fysom({'initial': 'init',
'events': [{'name': 'ucinewgame','src':'init','dst':'goinfinite'},
{'name': 'infinite','src':'goinfinite','dst':'goinfinite'},
{'name': 'move','src':'goinfinite','dst':'bestmove'},
{'name': 'infinite','src':'bestmove','dst':'goinfinite'},
{'name': 'ucinewgame','src':'bestmove','dst':'goinfinite'},
{'name': 'mate','src':'bestmove','dst':'end'},
{'name': 'reset','src':'bestmove','dst':'init'}],
'callbacks': {
'onucinewgame': onucinewgame,
'onbestmove': onbestmove } })
self.boomerang = Fysom({'initial': 'start',
'events': [{'name': 'startsearch','src':'start','dst':'godeeper'},
{'name': 'restart','src':'wait','dst':'start'},
{'name': 'exploremove','src':'godeeper','dst':'explore'},
{'name': 'exploremove','src':'explore','dst':'explore'},
{'name': 'noMoves','src':'explore','dst':'analyze'},
{'name': 'pause', 'src':'analyze','dst':'wait'}],
'callbacks': {
'ongodeeper': ongodeeper,
'onexplore': onexplore,
'onwait': onwait
} })
def resetGame(self):
self.gameStatus["startpos"] = 'startpos'
self.gameStatus["moves"] = []
self.gameStatus["moveDepths"] = {}
self.gameStatus["fen"] = True,
self.gameStatus["centipawns"] = 0
self.gameStatus["currentMove"] = 1
self.gameStatus["startPlayer"] = 'w'
self.gameStatus["player"] = 'w'
self.gameStatus["JSONlines"] = []
self.gameStatus["JSONcurrentLine"] = {}
self.gameStatus["JSONmoves"] = []
self.gameStatus["JSONcurrentMove"] = {}
def findBoomerang(self, startpos):
self.resetGame()
self.gameStatus["startpos"] = startpos
while True:
if self.boomerang.isstate("start"):
res = self.manager.get()
if re.search('^Stockfish', res):
self.initialize.uci(self.gameStatus)
if re.search('^uciok', res):
self.initialize.isready()
if re.search('^readyok', res):
self.boomerang.startsearch(self.movesList, self.movesListCP, self.searchingDepth, self.gameStatus, self.cp)
elif self.boomerang.isstate("wait"):
self.initialize.uci(self.gameStatus)
self.manager.clear()
self.boomerang.restart()
elif self.boomerang.isstate("godeeper"):
self.boomerang.exploremove(self.movesList, self.movesListCP, self.totalMoves, self.exploreDepth, self.gameStatus)
elif self.boomerang.isstate("analyze"):
break
self.boomerang.pause()
return json.dumps(self.gameStatus["JSONlines"])