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


Python Board.asXFen方法代码示例

本文整理汇总了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
        
开发者ID:jskurka,项目名称:PyChess-Learning-Module,代码行数:69,代码来源:UCIEngine.py


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