New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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. |
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.
`
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: