-
-
Notifications
You must be signed in to change notification settings - Fork 558
Closed
Description
Hello!
I am a new user of this API. Thank you very much. It is really a great work. I would like to ask a question which I could not solve: how can I create a PGN output from a running game: I have written following simple program as tournment of two compuer chess engines:
##########################################
# a very simple tournment between two uci engines
##########################################
import chess
import chess.uci
board = chess.Board()
engine = chess.uci.popen_engine("stockfish")
engine.uci()
while True:
board.reset()
while not board.is_game_over():
engine.position(board)
bestmove, ponder = engine.go(movetime=1000)
# print bestmove
board.push(bestmove)
print board
print board.fen()
print board.result()Now I would like not only to have a fen represenation when a game has finished, but also a pgn export. So my question is: how can I record all moves and checks and mates etc during a game play, so that I could have a pgn represantation of all moves when the game has ended?
A simple example would be welcome. You are also welcome to use my example and your pgn extension as general example for other users.
Thank you very much,
Maciej
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels