Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: timing out and choosing a move

Author: Gerd Isenberg

Date: 12:28:12 07/26/04

Go up one level in this thread



>never in quiescense
>at the beginning of search
>
>search (...)
>{
>TimeCount--;
>if (TimeCount == 0)
>{
>  if (NoTimeLeft(...)) TimeOut = true;
>  TimeCount = 10000;
>}
>
>if (TimeOut) return -MaxValue;
>...
>}

Ok that TimeCount handling is like some (fullnodecount & ((2**N)-1) )
I guess you have a greater zero nodecounter anyway, so why a second redundant
variable?

Instead of asking TimeOut everywhere in the search,
one may use structured exception handling and throwing an TimeOut exception
instead:

search (...)
{
  FullNodeCount++;
  if ((FullNodeCount & 0x1fff) == 0 ) // each 8*1024
  {
     if (NoTimeLeft(...))
       throw TimeOutException;  // an enum or int or class
                         // unwind the stack until catched
  }
  ...
}



try
{
  rootSearch (...); // calls search as well
  ...
}
catch (TimeOutException e)
{
  // use best of pv so far...
  // if empty (should not occur, but during development)
  // use some valid generated move with static best score
}

Another idea is to control time out, except looking for a new iteration, by some
other parent thread, which handles i/o as well or performs a message loop inside
a GUI. The parent thread sets a boolean volatile NoTimeLeft variable
(classmember) "true" (by some setter). The working search thread(s) unwinds and
terminates.

Due to noTimeLeft is no more a function but only a "atomic" byte wise memory
read, there is almost no need for the modulus at all.

search (...)
{
  if ( m_NoTimeLeft )
    throw TimeOutException;  // an enum or int or class
                      // unwind the stack until catched
  ...
}

I'm not sure, whether it is an good idea, to simply kill search threads or even
processes by a parent process if no time is left and a best move was already
found.

Gerd


>
>>
>>On #2, there must be a happy median, like "has it searched
>>the pv from the prior iteration but changed its mind?" There
>>must be some condition that would allow me to accept that
>>change of mind. What is it?
>
>Just take the current best move from pv. Make sure that you never change pv if
>timeout flag is set and make sure that the last pv is allways searched first.
>
>>
>>Thanks,
>>
>>Stuart



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.