Skip to content
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

Fix unmaking of capturing move #25 #27

Merged
merged 1 commit into from
Nov 14, 2020

Conversation

na2hiro
Copy link
Contributor

@na2hiro na2hiro commented Oct 24, 2020

Fixes two issues including #25

  • When undoing capturing of a promoted piece, the piece should be decremented in hands, but it didn't.
  • When undoing promoting of a piece,
    • It always threw Inconsistent ("Cannot unpromote" case).
    • Not covered by unit test, but I believe that bitboard updates were incorrect

@@ -45,7 +45,7 @@ pub enum MoveError {
PerpetualCheckLose,
EnemysTurn,
NonMovablePiece,
Inconsistent,
Inconsistent(&'static str),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a message (reason) because it was difficult to understand what's happening

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, it'd make life a little easier ;)

Comment on lines -596 to +605
self.hand.decrement(cap.flip());
let unpromoted_cap = cap.unpromote().unwrap_or(*cap);
self.hand.decrement(unpromoted_cap.flip());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a fix for the first item. The rest is for the second and also for enriching error messages.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this does make sense 🎉

@nozaq nozaq added the bug label Nov 14, 2020
@nozaq nozaq merged commit 1a1aa8e into nozaq:master Nov 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants