Closed gdm3 closed 1 year ago
I cannot tell from your issue exactly what the bug is here. My hunch is that this is a timing / state bug with your program. Can you recreate the minimal code that shows a bug with chessboard2?
Adding onto that, an example of a fen string that board.fen() does not work on is rnbqkbnr/pppppppp/3P5/8/4P3/8/PPP3PPP/RNBQKBNR, but that fen string was generated with board.fen() itself, so it should work.
rnbqkbnr/pppppppp/3P5/8/4P3/8/PPP3PPP/RNBQKBNR
is not a legal FEN string (3P5
is 9 squares, PPP3PPP
is also 9 squares). Can you reproduce the code that caused chessboard2 to create it?
I will recreate an example later, but that fen string was returned by board.fen()
so it should be a legal fen string.
It seems like just making some certain illegal moves causes board.fen()
to return an invalid fen string, such as playing e4, d4, and then moving the d4 pawn to d7, 'capturing' the pawn. (not an actual legal move, obviously). This specific sequence returns rnbqkbnr/pppppppp/8/8/3PP3/8/PPP3PPP/RNBQKBNR
as the fen string when checking board.fen()
.
Quick example where you can try this: https://chessboard-test.noelb33.repl.co/
Thank you for following up on this :+1:
I found a one-character bug with the position->fen
function that I am pretty sure is the root cause here :upside_down_face:
Sorry for the trouble! I can imagine this would be quite frustrating to debug. This should be fixed with v0.5.0.
It seems like using
let x = board.fen()
to get the chessboard and then setting it back withboard.fen(x)
does not work if two pieces have moved already, and only if two pieces have moved already.I have code like this to send a request to my server to see if the move is valid or not, and if it isn't then don't show the move:
The funny thing is this works totally fine up until two pieces are changed on the board. Then it doesn't work at all. Am I overlooking something? If you
console.log
the fen before and after doing the changes, they're not any different, but if you logcur_board
it is different.Adding onto that, an example of a fen string that
board.fen()
does not work on isrnbqkbnr/pppppppp/3P5/8/4P3/8/PPP3PPP/RNBQKBNR
, but that fen string was generated withboard.fen()
itself, so it should work.