notnil / chess

chess package for go
MIT License
508 stars 126 forks source link

Error parsing moves in the opening #122

Open maxwellmax2023 opened 1 year ago

maxwellmax2023 commented 1 year ago
game := chess.NewGame(chess.UseNotation(chess.UCINotation{}))
book := opening.NewBookECO()
moves := "e2e4 g8f6 e4e5 f6d5 f1c4"
ml := strings.Split(moves, " ")

for _, move := range ml {

    if err := game.MoveStr(move); err != nil {
        break
    }
}
s := game.Moves()
p := book.Possible(s)
g2 := p[0]
m := g2.Game().Moves()

bestMove := m[5].String()

in this chunk of code bestmove should be "d5b6" instead of "b7b6". The problem seems to be pgn multidecoder at line 170 of the pgn.go file as evidenced also by thangng48 issue

https://github.com/notnil/chess/blob/e9ff96c9f2d309a51c820bc3068f2c4ec473664c/pgn.go#L170

maxwellmax2023 commented 1 year ago

To detail further: I have different package version on my machine. Version 1.5.0 responds correctly. Version 1.7.3 no more