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
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bitboard.h
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.

Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ inline int distance<File>(Square x, Square y) {

template<>
inline int distance<Rank>(Square x, Square y) {
return std::abs(rank_of(x) - rank_of(y));
return rank_of(Square(std::abs(x - y)));
}

template<>
Expand Down
Loading