title: Zobrist hashing in chess: why treat castling and En passant separately?
body: <p>I'm trying to implement <a href="https://www.chessprogramming.org/Zobrist_Hashing" rel="nofollow noreferrer">Zobrist Hashing</a> for a board game, so I read about it and its particular use in Chess games. It seems you first need to initialize an array of random 64 bits integer of size 64 (8x8), multiplied by the number of pieces.</p>
  <p>The thing I don't understand, is that you also need to add castling and &quot;en passant&quot;, as well as other combinations:</p>
  <ul>
  <li>One number for each piece at each square (ok with that)</li>
  <li>One number to indicate the side to move is black (?)</li>
  <li>Four numbers to indicate the castling rights (?)</li>
  <li>Eight numbers to indicate the file of a valid En passant square, if any (?)</li>
  </ul>
  <p>Bullet points marked with (?) are the ones I don't understand. Since every piece has already 64 possible possible moves (e.g. the whole chess board), why do you need to add castling and &quot;en passant&quot;? Why do you need to also add the side to move?</p>
  <p>I'm trying to understand this, because in other board games with other rules, I wouldn't know how to select which positions/combinations should be stored in the Zobrist initialization array.</p>
  <p>Thanks</p>