generate pgn of chess game python

Solutions on MaxInterview for generate pgn of chess game python by the best coders in the world

showing results for - "generate pgn of chess game python"
Noreen
14 Jul 2016
1>>> import chess.pgn
2>>>
3>>> pgn = open("data/pgn/kasparov-deep-blue-1997.pgn")
4>>>
5>>> first_game = chess.pgn.read_game(pgn)
6>>> second_game = chess.pgn.read_game(pgn)
7>>>
8>>> first_game.headers["Event"]
9'IBM Man-Machine, New York USA'
10>>>
11>>> # Iterate through all moves and play them on a board.
12>>> board = first_game.board()
13>>> for move in first_game.mainline_moves():
14...     board.push(move)
15...
16>>> board
17Board('4r3/6P1/2p2P1k/1p6/pP2p1R1/P1B5/2P2K2/3r4 b - - 0 45')
18