當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。