notnil / chess

chess package for go
MIT License
521 stars 133 forks source link

Error parsing moves in the opening #122

Closed maxwellmax2023 closed 2 days 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

notnil commented 2 days ago

https://github.com/lichess-org/chess-openings/blob/master/b.tsv

138B02Alekhine Defense: Kmoch Variation1. e4 Nf6 2. e5 Nd5 3. Bc4 Nb6 4. Bb3 c5 5. d3

https://go.dev/play/p/s4ZY3M51GsD

this code returns:

Alekhine Defense: Kmoch Variation

Which is correct on the latest code base.