Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Problems implementing hash tables

Author: Scott Gasch

Date: 16:28:33 02/10/02

Go up one level in this thread


You know reading this again I realize I misspoke and probably did more to
confuse you than to clarify.  Let me try this again.

When your search finds a mate it returns a score that is based upon that mate's
distance from the root of the search.  So if you find a mate somewhere in your
search you will build the mate score based upon the distance from the root.

When hashing such a score you can get yourself into trouble.  Instead of hashing
the mate score as distance from root you want to hash it as distance from the
node you are hashing.  For example, if you are at ply 5 and the recursive search
has returned a +mate in 12 ply score.

If you simply store "mate in 12 ply" for this node's value you have trouble if
you come across the same position later at a different distance from the root.
Like you see it at ply 3, for example.  Well then you lookup the hash table
value and its wrong -- it says this is a mate in 12 ply but its not anymore.
This time it's a mate in 10 ply from the root because you're 2 ply closer to the
root when you saw it.

So hash the distance from the current position to the mate instead of the
distance from the root to the mate.  To do this simple subtract ply from the
mate score.  In our example we have mate in 12 ply and we first see it at ply 5.
 Store as mate in 12 - 5 ply (mate in 7 ply) in the hash table.

Then when you hit it later at ply 3, get the real score of the mate from the
root by adding in ply.  So you lookup mate in 7 ply and add current distance
from root (3) to get "mate in 10 ply from the root".

I hope I've been more clear this time.  Good luck

Scott



This page took 0.01 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.