Kumar-laxmi / Algorithms

A Repository for algorithms in C, C++, Python and Java
Apache License 2.0
315 stars 365 forks source link

Zobrist Hashing in C,C++,Java and Python #1585

Closed Ikshvaku24 closed 5 months ago

Ikshvaku24 commented 1 year ago

Zobrist hashing is a hashing technique used in board game algorithms, particularly in game-playing programs like chess engines. It was introduced by Albert Zobrist in the 1970s as a method to efficiently store and compare board positions in games with large state spaces. The idea behind Zobrist hashing is to assign a unique hash value to each possible state of the game board.

Steps how zobrist hashing works:

  1. Assign a random hash value to each possible combination of game board squares and pieces. These hash values are typically precomputed and stored in a lookup table.
  2. Initialize a hash value for the current board position to zero.
  3. When computing the hash value for a given board position, XOR (exclusive OR) the hash values associated with the squares and pieces present on the board.
  4. Repeat step 3 for each square and piece on the board, XORing the corresponding hash values.
  5. The resulting XORed value represents the unique hash value for the current board position.
jahnvisahni31 commented 1 year ago

Hey, I am SSOC'23 contributor and would like to contribute to this issue. Please assign this issue to me!!

Shankhadweep commented 1 year ago

@Kumar-laxmi I would like to work on this issue under SSOC'23.Kindly assign this issue to me.

github-actions[bot] commented 6 months ago

Stale issue message