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


Python Fysom.noMoves方法代码示例

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


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

示例1: __init__

# 需要导入模块: from fysom import Fysom [as 别名]
# 或者: from fysom.Fysom import noMoves [as 别名]

#.........这里部分代码省略.........
            gameStatus = e.args[4]

            movesList = e.args[0]
            movesListCP = e.args[1]
            totalMoves = e.args[2]
            exploreDepth = e.args[3]

            startpos = gameStatus["startpos"]

            for key in gameStatus["moveDepths"].keys():
                move = key
                gameStatus["moves"] = [move]
                gameStatus["currentMove"] = 1
                gameStatus["player"] = gameStatus["startPlayer"]

                self.explore.ucinewgame(exploreDepth, startpos, move, gameStatus)
                while True:
                    res = self.manager.get()
                    if re.search("^info", res):
                        self.explore.infinite()
                        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},
            }
        )
开发者ID:Nixonite,项目名称:chesscomputer,代码行数:69,代码来源:boomerang_server.py

示例2: __init__

# 需要导入模块: from fysom import Fysom [as 别名]
# 或者: from fysom.Fysom import noMoves [as 别名]

#.........这里部分代码省略.........
			gameStatus = e.args[4]
			
			movesList = e.args[0]
			movesListCP = e.args[1]
			totalMoves = e.args[2]
			exploreDepth = e.args[3]

			startpos = gameStatus["startpos"]

			for key in gameStatus["moveDepths"].keys():
				move = key
				gameStatus["moves"] = [move]
				gameStatus["currentMove"] = 1
				gameStatus["player"] = gameStatus["startPlayer"]

				self.explore.ucinewgame(exploreDepth, startpos, move, gameStatus)
				while True:
					res = self.manager.get()
					if re.search('^info', res):
						self.explore.infinite()
						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'},
开发者ID:M0nd4,项目名称:chesscomputer,代码行数:70,代码来源:boomerang_server.py


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