Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Subtle Hash Table Bug -- Help for others

Author: Bruce Moreland

Date: 09:14:51 03/30/99

Go up one level in this thread



On March 30, 1999 at 00:17:24, William Bryant wrote:

>I found a subtle hash table bug present, it turns out, in the last 8 builds of
>Screamer.  I have followed with interest the hash table and other implementation
>discussions, I haven't seen this one discussed.  If this is old news, sorry.
>
>When storing a mate score, store the score in the table as MATE (a predefined
>constant for mate), not MATE - ply (or a mate in n score).  The score can be
>converted to mate in n when extracted from the table.  The result of storing
>mate in n in the hash table is that the score may report a incorrect distance to
>mate, leading the engine to follow the wrong PV.  I was getting Mate in 4
>changing to Mate in 2 but the PV totally lost the opportunity to checkmate the
>king.
>
>It wish to note, that it was reviewing an older version of Crafty source code
>that I discovered that Bob was converting his mate scores after extraction.  I
>asked why, (since I was storing the distance to mate as well), then Bob's
>comments sprang to mind "The hash table stores postions, not pathways to
>positions".  The distance to mate dependes on the depth at the time the position
>is encountered again, not the depth when it was stored.
>
>Anyway, if any other amature is storing mate in n positions in their hash table,
>I hope this helps.

This is a known problem.

The problem is that the score is dependent upon the distance between where you
are now and the root, so if you find this same position at a different distance
from the root of the tree, it should score differently.

A solution would be to subtract out the part of the score that is due to the
distance from the root, and add it back in when you probe the table.

So if you find a mate in 3 at a given node, and you are 9 plies from the root,
normally you score this as mate in 12, but this has the bugs you discovered.

What you'd do instead is subtract the "9" from the score and store mate in 3 in
the table, and when you look it up later, and let's say you happen to be 2 plies
from the root, so you add this in to get mate in 5.

This is kind of complicated and I found that I was always fighting bugs in this.

So what I do when I find an exact mate score is I store it as >= mate in 500.  I
can still often cut off, but if I'm trying to differentiate between mate in N
and mate in M I still have to do the search.

bruce



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.