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


Python Board.push方法代码示例

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


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

示例1: pv_to_san

# 需要导入模块: from chess import Board [as 别名]
# 或者: from chess.Board import push [as 别名]
 def pv_to_san(self):
     if(self.san_arr == None):
         return ""
     else:
         try:
             pv_san = []
             board = Board(self.san_arr[0])
             moves = self.san_arr[1]
             for uci in moves:
                 move = Move.from_uci(uci)
                 if(move in board.pseudo_legal_moves):
                     pv_san.append(board.san(move))
                     board.push(move)
             if(len(pv_san) > 0):
                 s = ""
                 white_moves = True
                 move_no = (self.no_game_halfmoves//2)+1
                 if(self.no_game_halfmoves % 2 == 1):
                     white_moves = False
                     s += str(move_no)+". ... "
                     move_no += 1
                 for san in pv_san:
                     if(white_moves):
                         s += " "+str(move_no)+". "+san
                         move_no +=1
                     else:
                         s += " "+san
                     white_moves = not white_moves
                 return s
             else:
                 return ""
         except ValueError:
             return ""
开发者ID:jasiegel4,项目名称:jerry,代码行数:35,代码来源:engine_info.py

示例2: _accept_node

# 需要导入模块: from chess import Board [as 别名]
# 或者: from chess.Board import push [as 别名]
    def _accept_node(self, parent_board: chess.Board, visitor: "BaseVisitor[ResultT]") -> None:
        if self.starting_comment:
            visitor.visit_comment(self.starting_comment)

        visitor.visit_move(parent_board, self.move)

        parent_board.push(self.move)
        visitor.visit_board(parent_board)
        parent_board.pop()

        for nag in sorted(self.nags):
            visitor.visit_nag(nag)

        if self.comment:
            visitor.visit_comment(self.comment)
开发者ID:niklasf,项目名称:python-chess,代码行数:17,代码来源:pgn.py

示例3: main

# 需要导入模块: from chess import Board [as 别名]
# 或者: from chess.Board import push [as 别名]
def main():
    args = docopt(__doc__)
    game, title = choose_game(args["<PGNfile>"])
    b = Board()
    moves, annotations = [], []
    for i, move in enumerate(game.mainline_moves()):
        if i % 2 == 0:
            moves.append(f"{int(i/2)+1}. {b.san(move)}")
        else:
            moves[-1] += f" {b.san(move)} "
        b.push(move)
        display(b, title, moves)
        annotate = input("> ")
        if annotate:
            annotations.append((int(i / 2) + 1, annotate))
    print(annotate)
    print("FINISHED")
开发者ID:ChrisDavison,项目名称:pyscripts,代码行数:19,代码来源:pgnviewer.py


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