

If we now want to get the Zobrist hash code of a certain position, we initialize the hash key by xoring all random numbers linked to the given feature, e.g. This is also useful for things like opening books, where the positions in the book can be stored by hash key and be used portably across machines, considering endianness. This means that whatever platform the program is run on, it will use the exact same set of Zobrist keys.
#ENPASS CHESS GENERATOR#
Programs usually implement their own Pseudorandom number generator (PRNG), both for better quality random numbers than standard library functions, and also for reproducibility. There are even proposals and implementations to use overlapping keys from unaligned access up to an array of only 12 numbers for every piece and to rotate that number by square. Since pawns don't happen on first and eighth rank, one might be fine with 12*64 though. This leaves us with an array with 781 (12*64 + 1 + 4 + 8) random numbers.

The main purpose of Zobrist hash codes in chess programming is to get an almost unique index number for any chess position, with a very important requirement that two similar positions generate entirely different indices. Wegman in 1977 and studied in more detail by Mihai Pătrașcu and Mikkel Thorup in 2011. Zobrist Hashing is an instance of tabulation hashing, a method for constructing universal families of hash functions by combining table lookup with exclusive or operations. In an early Usenet post in 1982, Tom Truscott mentioned Jim Gillogly's n-bit hashing technique, who apparently read Zobrist's paper early, and credits Zobrist in a 1997 rgcc post. A technique to transform a board position of arbitrary size into a number of a set length, with an equal distribution over all possible numbers, invented by Albert Zobrist.
