-
Notifications
You must be signed in to change notification settings - Fork 58
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
Produce valid FEN strings for game struct #49
base: master
Are you sure you want to change the base?
Conversation
Hey, @WalterSmuts , I'm going to need quite a few changes before I am willing to merge this. I have several issues.
If you would like to implement this, the better way to do this is by adding a function to the |
I think you're right :)
These changes are to conform with the standard meaning of the en passant square. I.e fixing #36. But I suspect a
Looks like I removed too much yeah. My intention was just to remove the logic enforcing Note:
|
This is in preparation for implementing the Display trait on the Game struct. The en_passant_target field is uesd in standard FEN notation and differs from the en_passant field in the following ways: * The rank they refer to, 3rd for en_passant vs 4th en_passant_target * The en_passant_target is always set on a double pawn push while the en_passant field is only set when it matters (i.e. only when it allows for an en passant capture the next move)
To keep the one to one correspondence between the Board and BoardBuilder structs we need to duplicate the en_passant_target definition for the board_builder struct.
In preparation for implementing the Display trait on the Game struct, we need to factor out the get_half_move_clock logic to avoid logic duplication.
I've gone ahead and factored the PR into smaller commits to make it easier to review. Here are the commit messages:
|
I can already tell this is much better than the original patch, I still have some nit-picking to do, but this is much closer to how the implementations should be. This is really two MRs, one for the FEN stuff, and one for the EP stuff. En-passantI think we can remove
Instead, I think The same argument can be made for FENI'm missing documentation on the In the Next up, the big one: it appears to me you've only implemented half of the move counter stuff. You seem to more-or-less correctly serialize everything (I haven't tested it myself yet), but you don't correctly _de_serialize the move counter yet. So, reading an FEN per that spec. is currently not supported. This should be implementable by adding a |
I'm not so sure. There is no context to infer
Meaning there will be occasions when we need to have
I'll add some. Good idea.
Since we're using it in two places, it needs to be factored out. The same logic is used to to implement the
I'm not 100% sure what you're suggesting here but it sounds like you're suggesting that the Board struct's
Interesting idea. Let me see if it works :) |
...into a separate get_pseudo_fen fn. This is in preparation for implementing the Display trait on the Game struct. We'll be using the get_psuedo_fen logic in the Dispay trait implementation. Once we implement the Display trait for the Game struct we'll be using the get_pseudo_fen function in two places: * In the Display trait implementation of BoardBuilder * In the Display trait implementation of Game
... to consider the half move clock and full move counter when deserializing from a FEN representation.
The test was found as a sample on: https://www.chessprogramming.org/Forsyth-Edwards_Notation The test exercises special-cases of: * En passant moves * Full move counter * Half move clock
Made the |
Bump |
1 similar comment
Bump |
Just wanted to say, I had to use @WalterSmuts fork with this change in order to get my app working. I've built a personal app that connects a UCI bot to my chessnut air. I was running into issues with not being able to play en passant and just using this fork fixed the issue. No code changes need on my part. I was pretty surprised to find that the chess crate was producing invalid fen. If there is something hold back this from being merged, I'd definitely be happy to help fix it to prevent people from running into the same issue I did. |
I had to do the same thing, @jimmyhmiller. Thanks @WalterSmuts. For beginners finding this issue who might not know what to do, you can just switch to
in your |
Fixes #46 and fixes #36