freeeve / pgn

a PGN (Portable Game Notation) chess game parser for golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PGNScanner fails on this game

andWhatShouldISay opened this issue · comments

[Event "World Rapid Women 2018"]
[Site "St Petersburg RUS"]
[Date "2018.12.27"]
[Round "6.34"]
[White "Zhukova, Natalia"]
[Black "Goltseva, Ekaterina"]
[Result "1-0"]
[WhiteElo "2377"]
[BlackElo "2153"]
[ECO "A34"]
[EventDate "2018.12.26"]

1.c4 c5 2.Nf3 Nf6 3.Nc3 e6 4.g3 b6 5.Bg2 Bb7 6.d4 cxd4 7.Qxd4 Bc5 8.Qd3 d5
9.cxd5 Nxd5 10.Ng5 Be7 11.Nxd5 Bxd5 12.Bxd5 Qxd5 13.Qxd5 exd5 14.O-O O-O
15.Rd1 Rd8 16.Nh3 Bf6 17.Nf4 d4 18.Bd2 Nc6 19.Nd3 Rac8 20.Rac1 Ne5 21.Nb4
Rc5 22.b3 Rdc8 23.Nd5 Rxc1 24.Nxf6+ gxf6 25.Bxc1 Rc2 26.Bf4 Rxe2 27.Kf1
Rxa2 28.Rxd4 Kg7 29.h3 Nc6 30.Rd7 Ra3 31.Rc7 Nd4 32.b4 Nb5 33.Rc4 Ra2 34.
Be3 Na3 35.Rg4+ Kf8 36.Rh4 Nc2 37.Bh6+ Ke7 38.Bg7 Ra4 39.Re4+ Kd7 40.Bxf6
Nxb4 41.Re7+ Kc6 42.Rxf7 Nd5 43.Be5 b5 44.Rxh7 b4 45.Rh6+ Kc5 46.Rh8 b3
47.Rc8+ Kb4 48.h4 Nb6 49.Re8 Ka3 50.h5 Nc4 51.Bg7 Ra5 52.g4 Rg5 53.h6 Rxg4
54.h7 Rxg7 55.h8=Q b2 56.Qf8+ Ka2 57.Re1 Rb7 58.Qg8 b1=Q 59.Rxb1 Rxb1+ 60.
Kg2 Rb4 61.f4 a5 62.f5 Kb2 63.f6 Ne5 64.Qe8 Ng4 65.f7 Rf4 66.Qb8+ Rb4 67.
Qh8+ Ka2 68.f8=Q Ne3+ 69.Kf3 Nc4 70.Qhg8 Kb3 71.Ke2 Ka4 72.Qe8+ Ka3 73.Qe7
Ka4 74.Qge8+ Kb3 75.Q8f7 Ka4 76.Qd7+ Ka3 77.Qd3+ Ka4 78.Qfd7+ 1-0

So it fails at 72.Qe8+ with an error "pgn: attacker not found"

The mistake is here:
for {
f++
testPos := PositionFromFileRank(f, r)
if b.checkQueenColor(testPos, color) && (!check || !b.moveIntoCheck(Move{testPos, pos, NoPiece}, color)) {
retPos = testPos
count++
//we need to insert break here!!
} else if testPos == NoPosition || b.containsPieceAt(testPos) {
break
}
}

Also "break" should inserted in every such "for"

Thanks for the PR!