fix: reset halfmove counter on non-pawn captures - #24
Merged
Disservin merged 2 commits intoJul 9, 2026
Conversation
Disservin
reviewed
Jul 9, 2026
|
|
||
| // Update halfmove clock | ||
| if pt == PieceType::Pawn { | ||
| if pt == PieceType::Pawn || is_capture { |
Owner
There was a problem hiding this comment.
I think you can simply move this part (the if and else) above the // capture piece and then we don't need this is_capture variable
Contributor
Author
There was a problem hiding this comment.
Ah yeah good point, I should have thought of that, that's a simpler fix. Have pushed
Owner
|
published v0.6.5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi, I'm working on datagen for my own chess engine, and have been using this crate for the binpack compression.
I noticed in testing that my own engine and this crate were diverging on the halfmove clock after certain moves. The issue is that while you're resetting the halfmove clock after a capture, you're then unconditionally incrementing it further down if the piece is not a pawn, clobbering the previous reset, which means that any capture made by a non-pawn is not resetting the halfmove clock. This fixes that.
I've also added a unit test which fails without the actual code changes, and passes with the changes.
Thanks for the excellent library!