Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Problems implementing hash tables

Author: Miguel A. Ballicora

Date: 16:49:01 02/10/02

Go up one level in this thread


On February 10, 2002 at 19:28:33, Scott Gasch wrote:

>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

I never understood what the people is doing with the mate values, I always
get confused. I am glad that I came up with my own approach before I asked or
saw any post about it. :-)

What I do in pseudo code in Gaviota is

search (alpha, beta)
{
   adjust_in (&alpha, &beta); /* increments alpha += 1 and beta += 1 if they
                                are positive mate values, do the opposite if
                                it is a negative mate value */
   probe_hashtables_normally()

   loop { /* normal alpha beta stuff */
    makemove();
    value = search_moves_for_best_value(-beta, -alpha);
    unmakemove();
    best = keep the best value;
   }

   store_in_hashtables_normally();

   adjust_out(&best); /* decrement best -= 1 if it is a +mate value
                         increment +=1 if it is a -mate value */
   return best;

}

And basically, I do not do anything else. I store in the hashtables without
any change. adjust_out() it is used too when I return early.

Regards,
Miguel




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.