Draw by repetion missed when using a hash table

Discussion of chess software programming and technical issues.

Moderator: Ras

Pierre Bokma
Posts: 31
Joined: Tue Dec 07, 2010 11:19 pm
Location: Holland

Draw by repetion missed when using a hash table

Post by Pierre Bokma »

Hi,

My engine finds a draw by repetition without any problems but once is start using a hash table, the engine cannot find the draw anymore not even after an extensive search. I am using a special position for testing with a draw by repetition in 8 moves. Without the table my engine finds it without a problem, including the table it will not find it, not even after a 15 ply search!

I am sure this is a basic question that has been asked a zillion times before, so i am hoping for a usable answer.

I use the hash key to look fo draws and my engines does not use anything fancy, just pvs with a hash table.

regards and any help appreciated.
Pierre
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Draw by repetion missed when using a hash table

Post by bob »

Pierre Bokma wrote:Hi,

My engine finds a draw by repetition without any problems but once is start using a hash table, the engine cannot find the draw anymore not even after an extensive search. I am using a special position for testing with a draw by repetition in 8 moves. Without the table my engine finds it without a problem, including the table it will not find it, not even after a 15 ply search!

I am sure this is a basic question that has been asked a zillion times before, so i am hoping for a usable answer.

I use the hash key to look fo draws and my engines does not use anything fancy, just pvs with a hash table.

regards and any help appreciated.
Pierre
There are a couple of issues, and there is no satisfactory solution to fix everything.

1. Obviously you should check for repetition before you do a hash probe.

2. That helps, but it doesn't solve it, because you can reach position P in the search and store a score that is not a draw, since this is the first time you have reached this position. But if you reach it through a path where there will be a second repetition, you will likely find hash entries from that first search that cut this search off before you see the repetition.

3. You will find the same problem when dealing with 50 moves.

4. Not storing draw scores in the hash table doesn't solve the problem. It might help with the problem of thinking something is a draw when it is not, but not the reverse.
xmas79
Posts: 286
Joined: Mon Jun 03, 2013 7:05 pm
Location: Italy

Re: Draw by repetion missed when using a hash table

Post by xmas79 »

Hi,
I do the following:
a) check for draw by repetition or 50 moves rule before TT probe
b) when I do TT probe and find an exact match check again for draw by rep or 50 moves.

This seems that did the trick, but I'm always open to see that I didn't take the right approach. Can you post the position?

Thanks,
Natale.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Draw by repetion missed when using a hash table

Post by bob »

xmas79 wrote:Hi,
I do the following:
a) check for draw by repetition or 50 moves rule before TT probe
b) when I do TT probe and find an exact match check again for draw by rep or 50 moves.

This seems that did the trick, but I'm always open to see that I didn't take the right approach. Can you post the position?

Thanks,
Natale.
That is simply a "partial solution". The only real solution is to include path information in the hash signature. But that absolutely kills hash table hits. It's far worse than the "draw bug".