Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Search instabilities when re-using hashtables

Author: Sune Fischer

Date: 13:02:45 06/18/02

Go up one level in this thread


On June 18, 2002 at 12:11:57, Robert Hyatt wrote:
>
>OK...  define "MATE" as 32768, for now.
>
>If you find a move at the root that leads to a mate in 4, the score
>will typically be 32768 - 8 since you find you are mated at ply=8 and
>you return MATE-ply (I do, anyway).  Therefore, the root score that
>gets backed up will be 32760, and so far, all is well.  That means that
>the "mate score" that gets returned from ply = 8 has to be - ( MATE - PLY )
>so that - is bad for the side on move at ply=8.
>
>Note that you have 4 moves for the program in the path, the move at
>ply=1, 3, 5 and 7.  When you store a hash table entry at ply=7, you
>should store MATE-1, since the move at ply 7 will result in a MATE at
>ply=8.  At ply 5, you should store MATE-3, at ply 3 you should store MATE-5
>and if you want to store the entry at the root, it would be MATE-7.
>
>All this means is that at any point in the path that terminates in a mate
>score of any kind, you have to adjust the score so that it is a mate-in-N
>from the current ply, not from the root.  Because the root score is wrong
>at the current ply, since we are _closer_ to the final mate than we were at
>the root of the search.
>
>If that isn't clear enough, ask again.  You can find how I return a mate score
>by looking at the bottom of search.c in Crafty (look for string MATE).  You can
>find how I adjust the mate score before I store it in the hash table by looking
>at hash.c, module Store()...
>
>Bob

I think that _is_ what I'm doing!?

#define CHECKMATE    100000
#define CMSCORE       99000

search() {
..
  if (!movesfound) {
    if (InCheck(wtm))
       score=-CHECKMATE+depthroot;
    else
       score=DRAWSCORE;
  }
...
}

hasprobe() {
...
  switch (phash->flag) {
  case HASH_EXACT:
    if (abs(score)>CMSCORE){
       if (score>0)
          score-=depthroot;
       else
          score+=depthroot;
    }
...
}

hashstore() {
...
   if (abs(score)>CMSCORE){
      if (score>0)
          score+=depthroot;
      else
          score-=depthroot;
   }
...
}

"depthroot" is just distance to the root position we are searching, I assume it
is identical to yours "ply" variable.

Something must be wrong, I get weird results, it does work fine, it seems, but
when I look at the log I'm worried.

This position was from a quick test game, it's mate in 3, but I get mate in 1
three times in a row, but it doesn't have a problem playing the right moves,
really strange...
[D]1r2qrk1/n5p1/1p1p2P1/p2p2P1/2P1pPK1/P1PB2P1/2Q5/1R5R w - - 0 1

-S.



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.