-
Notifications
You must be signed in to change notification settings - Fork 913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#319: add null move functionality #451
base: master
Are you sure you want to change the base?
Conversation
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:
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! |
src/chess.ts
Outdated
@@ -101,6 +101,7 @@ const FLAGS: Record<string, string> = { | |||
PROMOTION: 'p', | |||
KSIDE_CASTLE: 'k', | |||
QSIDE_CASTLE: 'q', | |||
NULL_MOVE: 'nm', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The FLAGS.NULL_MOVE value should be a single character. As written, the n
in nm
collides with FLAGS.NORMAL. Maybe use '-'?
The whole flag system is an artifact of some C code I wrote years ago, and is kinda kludgy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed this with the suggested value '-'
src/chess.ts
Outdated
@@ -1961,6 +1981,8 @@ export class Chess { | |||
output = 'O-O' | |||
} else if (move.flags & BITS.QSIDE_CASTLE) { | |||
output = 'O-O-O' | |||
} else if (move.flags & BITS.NULL_MOVE){ | |||
output = SAN_NULLMOVE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you just return SAN_NULLMOVE here to skip the rest of this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I fixed this.
@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:
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!