Answers.Body: <p>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:</p>
  
  <ol>
  <li><p>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.</p></li>
  <li><p>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.</p></li>
  </ol>
  
  <p>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.</p>
  
  <p>Not sure, why you need this, but if you need to store positions somewhere, I'd recommend to use a <code>dictionary</code> or a <code>map</code>, 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.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-28T16:08:15.130Z
Answers.LastActivityDate: 2018-06-28T16:08:15.130Z
Answers.UserDisplayName: lenik
Body: <p>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.</p>
  
  <p>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).</p>
  
  <p>Zorbist use 64 bits as I remember.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-27T01:20:18.977Z
Comments.Text: http://talkchess.com/forum/viewtopic.php?t=57065&highlight=compress+fen
Comments.UserDisplayName: SmallChess
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-27T04:46:27.267Z
Comments.Text: 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.
Comments.UserDisplayName: hoacin
Tags: <programming><chess-algorithms>
Title: What is alternative to Zobrist hashing?
ThreadText: # What is alternative to Zobrist hashing?
  
  (Asked by: username_0 on 2017-07-26)
  
  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.
  
  **Tags:** programming, chess-algorithms
  
  > **Comments:**
  > **username_1**: http://talkchess.com/forum/viewtopic.php?t=57065&highlight=compress+fen  
  > **username_2**: 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.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2018-06-28. Score: 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.
  
  
  ---
  
  