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

Zobrist Hashing #3

Open
kuket15 opened this issue Oct 12, 2021 · 1 comment
Open

Zobrist Hashing #3

kuket15 opened this issue Oct 12, 2021 · 1 comment

Comments

@kuket15
Copy link

kuket15 commented Oct 12, 2021

Thanks for sharing this interesting project with the community.

I just wonder why you opted for zobrist hashing. Isn't perfect hash achievable with an unsigned long?

In my mind something like the following could work:

  • 5 bits for each piece, to store the current position on the board (including the removed status). With 10 pieces -> 50 bits total.
  • 1 bit to store the active player.
  • 7 bits to store the current permutation of the 5 cards out of 120 possible permutations.

This leads to a perfect hash using 58 bytes and avoids any related hash collision issue.

Of course I might be wrong and that's why I'm asking.

Regards

Luca

@maxbennedich
Copy link
Owner

Hey Luca, thanks for your note, you're absolutely right, and in fact I have a C++ version which I'm not quite ready to publish yet, but which uses a scheme similar to what you suggest, with a 57 bit perfect hash (I believe 5 bits are enough to store the cards, assuming 30 permutations).

I think I was too influenced by chess engines when I originally wrote this that I didn't stop to think if it could be done in a better way :)

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