douglasbagnall / p4wn

a smallish turn-of-the-century javascript chess engine
http://p4wn.sf.net
113 stars 33 forks source link

incorrect FEN #17

Closed dusadrian closed 8 years ago

dusadrian commented 9 years ago

White trying to solve my previous issue, I thought one possible solution is to overwrite the current position by first generating the FEN via: var FEN = p4_state2fen(state) then state = p4_new_game(); p4_fen2state(FEN, state);

That seems to alleviate the problem, but got something even worst a few moves later: r2k3B/ppp2p1p/7n/3p4/8/1P3N2/P4qP1/4RRK1 w q - 0 17 1.Rxf2

r2k3B/ppp2p1p/7n/3p4/8/1P3N2/P4RP1/4R1K1 b q - 0 17 1...c5

r2k3B/pp3p1p/7n/2pp4/8/1P3N2/P4RP1/4R1K1 w q c6 1 18 2.Bf6+

r2k4/pp3p1p/5B1n/2pp4/8/1P3N2/P4RP1/4R1K1 b q - 2 18 2...Kd7

r7/pp1k1p1p/5B1n/2pp4/8/1P3N2/P4RP1/4R1K1 w q - 3 19 3.Re7+

r7/pp1kRp1p/5B1n/2pp4/8/1P3N2/P4RP1/6K1 b q - 4 19 3...Kd6

r7/pr2Rp1p/rr1k1B1n/2pp4/8/1P3N2/P4RP1/6K1 w q - 5 20

As you can see, the state2fen() command generated a FEN where on a6 and b6 there are two black rooks and they were not there a move earlier.

douglasbagnall commented 9 years ago

Here the FEN is also incorrect (as with #16), which you can easily see with the later positions:

r7/pp1k1p1p/5B1n/2pp4/8/1P3N2/P4RP1/4R1K1 w q - 3 19

The king is not even on the back line and the castle flag is still set.

P4wn should validate these when importing the FEN. Do you know where it came from in the first place?

dusadrian commented 9 years ago

I think the position was made up by myself in order to test the new interface I am working with. So the whole point was to interpret the FEN (which was incorrect in the first place), but got past p4wn's inspection... and that triggered a series of weird events. Alright, phew! (I thought there was something more deep that I was missing).

dusadrian commented 9 years ago

Actually, I don't remember for sure if I made it up or was taken from an actual game with p4wn in order to test the interface. Possibly, but I just can't say that for sure, it might have came up from an actual game (I do remember however that my code logged all FENs in the console in order to test the behavior position by position). I'll try to put it to more tests, if something else surfaces I will record the entire game for reproduction.