5

Zobrist hashing is very good method save position but it is not good to read position - is any good alternative to this algorithm which allow to store and restore position with minimum of bits.

For sure FEN is good to store position but it no the best representation using bits. I found that I can store position with use 202 without move count and half move count which is not need for position analysis (or not very important).

Zorbist use 64 bits as I remember.

2
  • 3
    talkchess.com/forum/…
    – ABCD
    Jul 27, 2017 at 1:20
  • Good is the discussion in the link. Putting pawn to first rank didn't come to my mind when dealing with this problem, I was storing to 26 bytes fixed size.
    – hoacin
    Jul 27, 2017 at 4:46

1 Answer 1

2

If you are looking for a way to restore the original position back, you need something totally unlike Zobrist, because the main goals when constructing a hashing algorithm are absolutely opposite to what you want:

  1. A hash should fit into the computer representation of an integer (32 bits or 64 bits, or, maybe in the future, 128 bits). Anything beyond that slows down things considerably.

  2. Hashes for the similar positions (which tend to arise during the game at the approximately same time) should be as different as possible to avoid hash collisions that, again, impact the performance.

So, basically, you don't have enough bits for the full representation, and even if you had, the use of easy-reversible conversion will harm the quality of the hashing and will slow down the engine.

Not sure, why you need this, but if you need to store positions somewhere, I'd recommend to use a dictionary or a map, that maps the Zobrist value to the FEN string or something similar. Maps have O(1) access time, so it's going to be quite fast, and you're only limited by the amount of memory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.