本文整理汇总了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")