def get_game(self):
# if the movelist is positioned part way through the game then
# we must redo all moves to get the full game
redo_count = len(gv.jcchess.get_redolist())
for i in range(0, redo_count):
gv.jcchess.redo_move()
game = chess.pgn.Game.from_board(self.chessboard)
# if we did any redo moves then undo them now to get things back
# the way they were
for i in range(0, redo_count):
gv.jcchess.undo_move()
game.headers["Event"] = "Computer Chess Game"
game.headers["Site"] = socket.gethostname()
game.headers["Date"] = datetime.strftime(datetime.now(), '%Y.%m.%d')
game.headers["Round"] = "-"
game.headers["White"] = gv.jcchess.get_player(WHITE)
game.headers["Black"] = gv.jcchess.get_player(BLACK)
return game
评论列表
文章目录