Author: James Robertson
Date: 20:15:59 02/05/99
Go up one level in this thread
On February 05, 1999 at 21:39:50, William Bryant wrote:
>My program play abnormal moves when I try to exit the search when the alloted
>search time is over.
>
>I check for time at the start of search (but not in search_root() and not in the
>QSearch),
>When this iteration of search exits with a score of zero, I break from >searching
>any further moves or from any further updating of the PV. The search should
>still return the best move previously found prior to
>time being flagged, shouldn't it?
>
>Any help with placement of time code in the search would be helpful.
>
>William
>wbryant@ix.netcom.com
I'm not sure I understand what you are doing, but there are several
possibilities:
A) You are not saving the pv in a safe place when an iteration ends. I.e., you
could find a pv on ply 4, but start overwriting it on ply 5, so when you exit in
the middle of ply 5 you have a half-searched pv.
B) If your search uses score = 0 as a signal to exit, you will have problems
because 0 is a legitimate score for a position. Choose some wild score like
123456 or something that is unlikely (or impossible) to be the score returned by
your evaluate function.
I detect time up by checking how much time I have used every 10000 nodes or so.
If we have exceeded the time, then return an impossible value. Another way is to
set a paramater like terminate_search to true when you run out of time. Here is
my basic AB with time checking:
#define OUT_OF_TIME 123456
static int tc;
int AB(int alpha, int beta, int depth) {
//time checking
if (tc > 10000) {
tc = 0;
if (TimeUsed() > TimeLimit()) return OUT_OF_TIME;
} else tc ++
GenMoves()
while(moves) {
MakeMove();
score = -AB(-beta, -alpha, depth -1);
UnMakeMove();
//important. we don't want the OUT_OF_TIME to be treated as a valid score.
if (score == -OUT_OF_TIME) return OUT_OF_TIME;
if (score > alpha) {
alpha = score;
SavePV();
}
if (alpha >= beta) return alpha;
}
}
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.