Open ppeloton opened 8 months ago
Thanks for the PR @ppeloton.
This is a good start on the null move logic. A couple of random questions that I haven't really thought through yet:
.move()
function? I think there's a lot to think about here. A dedicated function would keep .move()
consistent with the results of .moves()
. It also side-steps the issue of not being able to enter a null move when using the verbose move format. A lot of people have been asking for setSideToMove
function. Could this be considered a null move? Could we combine the two?this._history.length === 0
) be omitted from history? Omitting it would require modifying the starting FEN and updating the Setup
header. This relates to the previous question about setSideToMove
.I'd like to let this PR soak for a bit to let us (and others) ponder some of these questions. Thanks again for submitting!
@jhlywa : Happy to contribute and thank you for your good feedback and questions. Generally, I think that null moves do not have one common standard, so if we want to implement this in the package, the developers have to make choices and document how null moves are handled in chess.js
About your questions:
Exporting/Importing in pgn: Just the SAN for a null move has no standard (see e.g. https://chess.stackexchange.com/questions/14072/san-for-nullmove), so exporting / importing of null moves is probably differently supported. I personally use Scid, which supports importing/exporting of null moves in pgn files (using SAN '--').
a seperate method for null moves sounds good (e.g. makeNullMove()
) sounds like a good way to implement it. Even more if there is a wish for setSideToMove
functionality (if I understand it correctly, it basically corresponds to making a null move and giving the turn to the otherside).
Rules relating null moves: I have not found a standard for this. But using Scid as a reference, the program allows multiple null moves in succession but no null moves when one is in check. I could try to find out if there are more rules in Scid related to null moves and we good take that as a starting point for this package.
I am happy to continue the discussion!
Sorry, I forgot to run the prettify command. I hope now everything is fixed!
Implemented null move logic for SAN '--' and added a simple test case. Please review, I am open for discussions!