本文整理汇总了Python中pychess.Utils.Board.Board.asXFen方法的典型用法代码示例。如果您正苦于以下问题:Python Board.asXFen方法的具体用法?Python Board.asXFen怎么用?Python Board.asXFen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pychess.Utils.Board.Board
的用法示例。
在下文中一共展示了Board.asXFen方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: UCIEngine
# 需要导入模块: from pychess.Utils.Board import Board [as 别名]
# 或者: from pychess.Utils.Board.Board import asXFen [as 别名]
#.........这里部分代码省略.........
def _newGame (self):
print >> self.engine, "ucinewgame"
def _searchNow (self, ponderhit=False):
log.debug("_searchNow: self.needBestmove=%s ponderhit=%s self.board=%s\n" % \
(self.needBestmove, ponderhit, self.board), self.defname)
with self.moveLock:
commands = []
if ponderhit:
commands.append("ponderhit")
elif self.mode == NORMAL:
commands.append("position fen %s" % self.board.asFen())
if self.strength <= 3:
commands.append("go depth %d" % self.strength)
else:
commands.append("go wtime %d btime %d winc %d binc %d" % \
(self.wtime, self.btime, self.incr, self.incr))
else:
if self.mode == INVERSE_ANALYZING:
if self.board.board.opIsChecked():
# Many engines don't like positions able to take down enemy
# king. Therefore we just return the "kill king" move
# automaticaly
self.emit("analyze", [getMoveKillingKing(self.board)], MATE_VALUE-1)
return
print >> self.engine, "stop"
if self.board.asFen() == FEN_START:
commands.append("position startpos")
else:
commands.append("position fen %s" % self.board.asXFen())
commands.append("go infinite")
if self.needBestmove:
self.commands.append(commands)
log.debug("_searchNow: self.needBestmove==True, appended to self.commands=%s\n" % \
self.commands, self.defname)
else:
for command in commands:
print >> self.engine, command
if self.board.asFen() != FEN_START and getStatus(self.board)[1] != WON_MATE:
self.needBestmove = True
self.readyForStop = True
def _startPonder (self):
print >> self.engine, "position fen", self.board.asXFen(), \
"moves", toAN(self.board, self.pondermove, short=True)
print >> self.engine, "go ponder wtime", self.wtime, \
"btime", self.btime, "winc", self.incr, "binc", self.incr
#===========================================================================
# Parsing from engine
#===========================================================================
def parseLines (self, engine, lines):
for line in lines:
self.__parseLine(line)
def __parseLine (self, line):
if not self.connected: return
parts = line.split()
if not parts: return