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

int distance<Rank>(Square x, Square y) #5787

Closed
wants to merge 1 commit into from

Conversation

mstembera
Copy link
Contributor

@mstembera mstembera commented Jan 17, 2025

Simplify and optimize distance<Rank>(Square x, Square y) by reducing the number of operations.
No functional change
bench: 1379150

Simplify and optimize by reducing the number of operations.
No functional change
bench: 1379150
mstembera referenced this pull request in ces42/Stockfish Jan 17, 2025
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't this produce the wrong output for B1 (x = 1) and A2 (y = 8)?
|x - y| = 7 and >> 3 then gives 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ooops. You are absolutely correct! I actually wrote some test code to test all the square combinations but it turns out the test code had a bug in it also. Thanks.

@mstembera mstembera closed this Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants