Skip to content
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

multidecoder when decode PGN cause invalid board state #118

Open
thangng48 opened this issue Dec 3, 2022 · 0 comments
Open

multidecoder when decode PGN cause invalid board state #118

thangng48 opened this issue Dec 3, 2022 · 0 comments

Comments

@thangng48
Copy link

g := chess.NewGame(chess.UseNotation(chess.UCINotation{}))
pie(g.MoveStr("g1f3"))
pie(g.MoveStr("e7e5"))

fmt.Println(g.String()) // 1. g1f3 e7e5  *

pgn, err := chess.PGN(strings.NewReader(g.String()))
if err != nil {
   panic(err)
}

g2 := chess.NewGame(chess.UseNotation(chess.UCINotation{}), pgn)
fmt.Println(g2.String()) // 1. f2f3 e7e5  *

When decoding

chess/pgn.go

Line 168 in e9ff96c

decoder := multiDecoder([]Decoder{AlgebraicNotation{}, LongAlgebraicNotation{}, UCINotation{}})
, it tries every possible decoder and stop at not nil one.
Above example shows that it can cause invalid board state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant