Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: How to program search timeout ?

Author: Stuart Cracraft

Date: 17:08:16 02/04/98

Go up one level in this thread


In my program, timeout is handled in one basic place:
after searching all moves at the current ply, a check is performed:

if (SearchDepth == 0 && NodeCnt % TIMECHECK == 0)
{
   GetElapsed ();
   if ( (et >= targettime && !(rootscore - lastrootscore <= -25)) ||
        et >= maxtime)
    SET (flags, TIMEOUT);
}

I do not use signal() to interrupt the search, available on Unix and
PC's.
My tests showed the mere inclusion of this reduced my move
generator speed (and possibly other program speed) by double-digit
factors due to continual wakeups. Besides, not knowing where you
are in the search messes things up.

About the above code, whenever TIMECHECK more nodes (usually set to
a 3 digit number) have been searched after a node is fully searched
(all moves explored), then if the elapsed time so far is not greater
than the absolute max (usually 4x the targettime per move) alloted,
the search can terminate as long as the elapsed time is greater
than the targettime and we do not have a case where the score
has dropped a quarter pawn or more, in which case the search
may continue until 4x the nominal targettime.

The nominal targettime is determined by taking the number of seconds
left in the time control less a fudge factor of 10-15% and dividing
it by the number of remaining moves.

Since this algorithm usually runs a little long on a move-by-move
basis, my fudge factor is somewhat high to ensure that moves near
the end of the time control don't have to be instantaneous.

The above is supplemented with an additional increment based on
how recent the program has made a book move. The more recent such
a move was made, the more time is allocated up to 2x the nominal
targettime, declining to 1x the nominal targettime.

Exceptionally declining (continuously) scores can take up to 4x the
total nominal targettime as mentioned above. This is set before the
search begins, before the first iteration.

Additionally, the principal variation is handled carefully. Only
when the first move at the ply == 1 depth has been fully searched
is the principal variation updated and only if a timeout has not
occurred. Then this variation is copied to the "best PV found
so far" which is then used for things like displaying PV's or
reporting an actual move, thinking on opponent's time, etc.

I always start the next variation if a TIMEOUT condition does
not exist.

My current Win-at-Chess is 206 out of 300 at 5 seconds per problem
on a 25mhz 486. For comparison, on the same box, Crafty scores 209.
My Louguet is USCF 2280 and my Kaufman is USCF 2236 on the same
hardware.

--Stuart



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.