SindreSvendby / pgnToFen

Takes PGN as input and returns FEN
MIT License
30 stars 10 forks source link

Error in conversion #7

Open appletomato opened 5 years ago

appletomato commented 5 years ago

Hi, I receive the same error message that has been reported in an earlier issue:

IndexError('list index out of range',))

PGN-file to reproduce:

`[Event "41. Olympiad Women 2014"] [Site "Tromso NOR"] [Date "2014.08.05"] [Round "4.7"] [White "Hoang, Thanh Trang"] [Black "Ordaz Valdes, Lisandra Teresa"] [Result "1/2-1/2"] [WhiteElo "2485"] [BlackElo "2345"] [ECO "E35"] [EventDate "2014.08.02"]

1.d4 Nf6 2.c4 e6 3.Nc3 Bb4 4.Qc2 d5 5.cxd5 exd5 6.Bg5 c5 7.dxc5 h6 8.Bh4 g5 9.Bg3 Ne4 10.e3 Qa5 11.Rc1 Qxa2 12.Bb5+ Bd7 13.Bxd7+ Nxd7 14.Ne2 Nxc3 15.Nxc3 Qc4 16.Bd6 Nxc5 17.Bxc5 Qxc5 18.O-O Bxc3 19.Qa4+ Qc6 20.Qa3 Qa6 21.Qxa6 bxa6 22.Rxc3 O-O 23.Rc6 Kg7 24.h4 Rfb8 25.Rd1 Rxb2 26.Rxd5 Rb6 27. Rc7 Rb5 28.Rdd7 Rf8 29.Rxa7 a5 30.h5 g4 31.Rd4 Rg5 32.g3 Rxh5 33.Rxg4+ Rg5 34.Rf4 Re5 35.Kg2 Kg6 36.Ra6+ Kg7 37.Rg4+ Rg5 38.Rxg5+ hxg5 39.Kf3 f6 40. Rxa5 Re8 41.Kg4 Kg6 42.Ra7 Rb8 43.Kf3 Rb2 44.g4 Rb3 45.Re7 Ra3 46.Rd7 Ra2 47.Rd3 Ra1 48.Kg2 Ra2 49.Kg3 Ra1 50.f4 Rg1+ 51.Kh3 gxf4 52.exf4 Rh1+ 53. Kg2 Ra1 54.Rd6 Kf7 55.Kf3 Rg1 56.Rd7+ Ke6 57.Ra7 Rf1+ 58.Ke3 Rg1 59.Ra6+ Kf7 60.Kf3 Re1 61.Ra7+ Kf8 62.Ra3 Kf7 63.Re3 Rg1 64.Rc3 Re1 65.Rc2 Kf8 66. Re2 Rg1 67.Re4 Kf7 68.f5 Kf8 69.Ke3 Kf7 70.Kd4 Rd1+ 71.Kc5 Kg7 72.Rd4 Ra1 73.Rd7+ Kh6 74.Rf7 Kg5 75.Rg7+ Kf4 76.Kd6 Re1 77.Rg6 Ra1 78.Ke7 Ke5 79.Rg7 Ra6 80.Kf7 Kf4 81.Kg6 Kxg4 82.Rf7 Ra8 83.Rxf6 Rg8+ 84.Kf7 Ra8 85.Kg7 Kg5 86.Rf7 Ra5 87.f6 Ra6 88.Rf8 Rb6 89.f7 Rg6+ 90.Kh7 Rh6+ 1/2-1/2 `

You can check for yourself that the file contains a valid game and that it can be read by other chess software without problems. Please let me know if you need further help to investigate the problem.

JoniFlies commented 3 years ago

Same, mine crashes with "IndexError: list out of range" if game exceeds 4 pawn movements in the beginning, e.g. "['a4', 'e5', 'c4', 'd5']".

cajuncooks commented 3 years ago

The problem here and in #2 are identical: an insufficiently specific knight move. 14. Ne2 can be reached by both the g-knight and the c-knight (and in the other issue, ...Nc6 is the problem move).

This can be easily rectified by the user by specifying the knight move correctly (e.g. 14. Nge2), but I think a competent programmatic solution (and what I assume other chess software is doing) would be to create a copy of the board, go ahead with both moves, and try future moves against both sets until one fails; here, 14. ...Nxc2 would immediately rule out the c-knight and you no longer need to track that fork. If the game were to end on a draw on Ne2, just pick one, who cares.

@JoniFlies I don't get any kind of failure with with literally dozens of pawn moves. If you could provide more info, that would help.