Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: how do I determine 'mate in' depth?

Author: Sune Fischer

Date: 23:56:01 09/09/02

Go up one level in this thread


On September 09, 2002 at 20:01:29, scott farrell wrote:


>I have tried a variation on that, being :  INFINITY+(100-ply) - so it stays over
>infinity, so if it finds mate it returns nice a quickly. I guess your way
>continues to look for a shorter mate.
>
>But I still get the same sympton, the first move in the mate sequence returns
>INFINITY+99 (ie. INFINITY+100-1).
>
>I guess is something to do with wierd hashing, or my replacement scheme or
>something. i hope its not another bug in the hashtable.

You never ever want to go higher than INFINITY, the signs are important here.

Use INFINITY-ply (why add 100?)
So that INFINITY-1 is mate in 1 ply
INFINITY-2 mate in 2 plies (1 move) and in general INFINITY-x mate in x plies.

This works well for the a-b algorithm, your opponent will choose the move with
the highest score as always, so he will pick the move INFINITY-4 rather than
INFINITY-7, always the shortes way to the mate (you never mate if you take the
longest (instability)).

From Crafty's HashStore:
 if (type == EXACT) {
    if (value > MATE-300) value=value+ply-1;
    else if (value < -MATE+300) value=value-ply+1;
    if ((int) tree->pv[ply].pathl >= ply)
      word1l|=tree->pv[ply].path[ply];
  }
  else if (type == LOWER) {
    word1l|=tree->current_move[ply];
    value=Min(value,MATE-300);
  }
  else {
    value=Max(value,-MATE+300);
  }

The INFINITY-300 is just to see if it is a mate score, since only
mates can have scores that high and low.
I suspect there will be some problem if the mate is deeper than 300 plies as in
some egtbs, but perhaps Robert can explain?

Notice there is also a correction for bounds.

HashProbe:
    switch (type) {
      case EXACT:
        if (abs(val) > MATE-300) {
          if (val > 0) val-=(ply-1);
          else val+=(ply-1);
        }
        *alpha=val;
        return(EXACT);
      case UPPER:
        if (val <= *alpha) {
          *alpha=val;
          return(UPPER);
        }
        break;
      case LOWER:
        if (val >= *beta) {
          *beta=val;
          return(LOWER);
        }
        break;
    }

I had some instability until I added the min(score,mate-300).
Try that, and if it still doesn't work ask again :)

-S.

>Thanks
>Scott



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.