Clear or not to clear the hash tables

Discussion of chess software programming and technical issues.

Moderator: Ras

Dann Corbit
Posts: 12777
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Clear or not to clear the hash tables

Post by Dann Corbit »

Cardoso wrote:My engine sometimes makes a really bad move.
But when later I analise that position with the hash tables cleared it immediately sees the right move.
And that bad move goes to the end of the root move list.
So I'm pretty sure the entries in the hash table from the previous search are causing the problem.

When time is out I set a stopsearch flag, and at the top of the search if this flag is set I return zero.
Also when the stopsearch flag is set I store nothing in the hash tables.

Is this ok? Do you clear your hash tables before searching?
What value do you return when time is out?

Have you seen this king of behaviour in your engine?

Thanks in advance,
Alvaro
I suspect you may have a hash table bug. What do your hash table entries look like?

If you are using Zobrist hashing like most people, I suggest further that you create a second zobrist hash that does not operate incrementally, but builds up the complete hash from scratch given the board position. Then use a special compile flag to enable total rehash calculation. When you are searching, compare the recalculated hash with the incremental hash. If you ever see a difference you have a bug.
Cardoso
Posts: 363
Joined: Thu Mar 16, 2006 7:39 pm
Location: Portugal
Full name: Alvaro Cardoso

Re: Clear or not to clear the hash tables

Post by Cardoso »

I suspect you may have a hash table bug. What do your hash table entries look like?

If you are using Zobrist hashing like most people, I suggest further that you create a second zobrist hash that does not operate incrementally, but builds up the complete hash from scratch given the board position. Then use a special compile flag to enable total rehash calculation. When you are searching, compare the recalculated hash with the incremental hash. If you ever see a difference you have a bug.
I've done that in the past, but I've also changed my hash code since then.
I better do that test again. Thanks for the tip.

Alvaro