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

Bug in Board Hash trait implementation #75

Open
barakugav opened this issue Sep 24, 2022 · 3 comments
Open

Bug in Board Hash trait implementation #75

barakugav opened this issue Sep 24, 2022 · 3 comments

Comments

@barakugav
Copy link

The implementation of the Hash trait uses only the field 'hash' which is only affected by the pieces positions. On the other hand, the implementation of PartialEq compare all fields of the struct.
This causes unnecessary collisions in hashmap/hashset.
To solve it, the implementation of the Hash trait could simply use the get_hash() func.

@jordanbray
Copy link
Owner

I do not believe this is true. The reason the hash trait is implemented the way it is is to incrementally update the hash function. This is a technique called Zobrist hashing.

If you can find an example of such a collision, I'd love to see it.

@barakugav
Copy link
Author

The current implementation does not include the castling right for exmaple, or en passant value

@jordanbray
Copy link
Owner

Ahh. You are correct. I misread the comment.

@jordanbray jordanbray reopened this Feb 12, 2023
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

No branches or pull requests

2 participants