ajax333221 / isepic-chess

♞ JavaScript chess utility library.
MIT License
16 stars 3 forks source link

Manually modifying board properties yield unexpected results #11

Closed ajax333221 closed 3 years ago

ajax333221 commented 3 years ago

Example 1: If you load "rnbqkbnr/1pp1ppp1/p6p/8/8/1PNpP2P/PBPPQPP1/R3KBNR w KQkq - 0 7" then remove the a1 Rook (without modifying the castle rights), you will still be able to castle and a Rook will appear after castling.

Example 2: If you load "rnbqkbnr/ppp2ppp/3p4/2Pp4/8/8/PP2PPPP/RNBQKBNR w KQkq - 5 7" then add an en passant in d6 board.enPassantBos = "d6", playing the move "c5-d6" will cause the d5 Pawn to disappear.

Example 3: In the default position, if you change the half move clock board.halfMove = 99 then move a Knight, the "Is fifty-move rule?" will be true.

Etc.

ajax333221 commented 3 years ago

Messing with the board information will obviously cause unexpected results.

If someone must do some changes then he should consider rebuilding the fen with board.updateFenAndMisc() and then validating the new board.fen.

ajax333221 commented 3 years ago

This issue was created to guide future duplicates into this one and to leave a note to self about these edge cases.