Skip to content

check blunder move in pgn $4 or ?? #1035

Answered by MarkZH
sugizo asked this question in Q&A
Discussion options

You must be logged in to vote

After reading the game with first_game = chess.pgn.read_game(pgn), you'll want to iterate through first_game.mainline(). This will iterate through ChildNodes that contain all of the move information. For example:

import chess
import chess.pgn

pgn_book = 'book.pgn'

with open(pgn_book, "w") as f:
    f.write("""
[White "b"]
[Black "?"]
[Result "*"]
[FEN "8/1R3pk1/1P4p1/7p/7P/1r4P1/5PK1/8 w - - 0 1"]
[SourceVersionDate "2021.05.20"]
[SetUp "1"]
[Annotator "GM Petar G. Arnaudov"]
[PlyCount "25"]

1. Kf1 Rb2 2. Ke1 Kf6 3. f3 $1 Rb3 4. Kd2 Rxf3 $4 { this move loses } 5.
Rc7 $1 { [%cal Rc7c3] } (5. Kc2 Re3 $3 { everything else loses } 6. Rc7 Re8
7. b7 Rb8 $11) 5... Rb3 6. b7 Kf5 7. Kc2 Rb6 8. …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sugizo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants