Fix Bh4+ move

target was calculated without considering any suffices like + so it became "4+" instead of "h4".
This commit is contained in:
ekzyis 2024-09-26 11:05:04 +02:00
parent 2dc7cbf213
commit d1315b931b
2 changed files with 18 additions and 0 deletions

View File

@ -368,6 +368,8 @@ func parseMove(move string) (string, int, int, string, error) {
from string
)
move = strings.TrimSuffix(move, "+")
if move == "O-O" {
return "K", 5, 7, "g1", nil
}

16
chess/game_test.go Normal file
View File

@ -0,0 +1,16 @@
package chess_test
import (
"testing"
"github.com/ekzyis/chessbot/chess"
)
func TestGame001(t *testing.T) {
t.Parallel()
b := chess.NewBoard()
// this used to not parse because of the + at the end
assertParse(t, b, "d4 d5 Bf4 Nf6 e3 Ne4 Nc3 Nf2 Kxf2 e6 Qg4 Be7 Re1 O-O Kg3 Bh4+")
}