本文整理匯總了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 ""
示例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)
示例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")