I am making a chess engine and trying to implement Zobrist tables into my engine. From what I've read, my understanding is that you first calculate the Zobrist hashcode, then get the modulo of the hashcode divided by the size of your transposition table to find the storage index, then store all corresponding evaluation values into that index. I have a 64-bit Zobrist hash function written, but I have some questions on how to implement the actual table and Zobrist hashing in general:
- From what I've read, I should make an array of entries to store hash/eval info. How big should I make an array like that be to fit all the hash functions over an entire game?
- If the index at the modulo of a hash function is already stored, would I just follow regular hashing rules and keep traversing every n elements in the array from the index until I find an empty index? Is this also the protocol for Zobrist hashing?
- Correct me if what I'm saying is wrong, but I've read that when searching through the hash array, if the depth searched of a hashed position is different from the current depth you're searching, even if the hash value between your position and the hashed position is the same, you're not supposed to use the past evaluation. I understand the logic behind this, but doesn't this practically make Zobrist hashing useless? Realistically, an engine is not going to evaluate a position at the exact same depth every time, right?
- Say a position with hashcode
xand evaluation depth 5 exists in the hashtable and has a final evaluation of
a. I evaluate the same position
xbut this time at depth 6, so I find the new evaluation value to be
b. Do I update the past evaluation
xat depth 5 to the current evaluation
bat depth 6?