jayasurian123 / fen-validator

Validate the Chess FEN notation
10 stars 3 forks source link

False positives when side to move can capture the king #32

Closed pronode closed 8 months ago

pronode commented 1 year ago

Just try this position:

rnbqkbnr/2pp1ppp/p7/1p2Q3/4P3/5N2/PPPP1PPP/RNB1KB1R w - - 0 1

Returns true, should return false

jayasurian123 commented 1 year ago

hi @pronode , Thanks for the issue. I don't think this is a bug. FEN notation only represent the position of the pieces and the state. Rules of the games, checkmate, results are not represented here.

The reference of this library is in the section 6.1 https://ia902908.us.archive.org/26/items/pgn-standard-1994-03-12/PGN_standard_1994-03-12.txt

Adding move validation is beyond the scope of a fen validator. Move validation would differ according to the variant of the standard chess.

Let me know your thoughts!

pronode commented 1 year ago

Oh, okay then!

I thought it was a position validator as well :) It's a shame there is no such library.

Best wishes.

nlukic97 commented 8 months ago

Hey @pronode . There is a library which I used to validate chess moves for a project I built: chess.js

You can pass in a validated fen string into a new Chess object, and it will validate any following moves for you. Hope this helps!