This repository has been archived by the owner on Jan 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 135
PGN's Reader? #77
Comments
Playground: Its strange that adding it to the fixtures/pgn folder and including it in a test DOESN'T cause the issue. Something along the line (unique to the chess.PGN entry point) is trimming the space between |
I was able to reproduce this minimally: package main
import (
"log"
"strings"
"github.com/notnil/chess"
)
func main() {
game := chess.NewGame()
game.MoveStr("d4")
pgn, err := chess.PGN(strings.NewReader(game.String()))
if err != nil {
log.Fatal(err)
}
newGame := chess.NewGame(pgn)
log.Printf(newGame.FEN())
} It seems like the PGN parser doesn't handle when there's no space between the number and the algebraic notation. |
sumnerevans
added a commit
to sumnerevans/chess
that referenced
this issue
Dec 12, 2021
There were two main bugs that this fixes. * Fixes notnil#77: fixed parsing of PGNs where there is no space after the move number indicator. This used to work, but notnil#76 caused a regression. * Fixes notnil#78: using the regular expression allows for comments that don't have spaces separating the `{` and `}` tokens.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
`
func main() {
}
`
now, its output:
`
1.d4 d5 2.Bf4 Nc6 3.e3 Qd6 4.Bxd6 exd6 5.Nc3 Nf6 6.Qf3 Bg4 7.Qf4 O-O-O 8.Nb1 Nb4 9.c3 Nxa2 10.Rxa2 Re8 11.f3 Bd7 12.h3 Nh5 13.Qxf7 Rxe3+ 14.Be2 Ng3 15.b4 Nxh1 16.Rxa7 Ng3 17.Ra8# 1-0
chess: pgn decode error chess: failed to decode notation text "1.d4" for position rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1 on move 1
`
The text was updated successfully, but these errors were encountered: