Author: Dan Honeycutt
Date: 17:58:02 05/05/05
Go up one level in this thread
On May 05, 2005 at 19:32:58, Matthias Gemuh wrote:
>On May 05, 2005 at 17:29:31, Dan Honeycutt wrote:
>
>>On May 05, 2005 at 16:22:27, Kevin K wrote:
>>
>>>Do you return 0 or alpha when time is up during search?
>>>If 0 must be returned, why?
>>>If alpha must be returned, why?
>>>
>>>Thanks.
>>
>>If you abort the search due to time elapsing I recommend you set a flag. The
>>score you return doesn't matter (you don't have a score till you back up to the
>>root). Your search should check that flag before checking to see if the score
>>returned is above alpha/beta. If the flag is set then it returns immediately,
>>etc. till you spool back to the root. The move, score, and PV are all the best
>>you got before the abort.
>>
>>Regards
>>Dan H.
>
>
>
>
>OK. So with flag set at right position, return value can be anything as it
>must be ignored at root, if invalid.
>
>Matthias.
If the flag is set score is ignored everywhere. Pseudo code:
int Search(int alpha, int beta, int depth) {
if (depth == 0) return Eval();
if (time_spent >= time_alloted) {
abort_flag = TRUE;
return 0;
}
GenerateMoves();
while (moves_left) {
MakeNextMove();
score = -Search(-beta, -alpha, depth -1);
UnMakeMove();
if (abort_flag) return 0;
if (score > alpha) {
alpha = score;
if (score >= beta) return beta;
}
}
return alpha;
}
The root is similar with something like:
:
UnMakeMove();
if (abort_flag) return 0; //don't know if current move is good or bad
if (score > alpha) {
best_move = current_move; //now we know something
best_score = alpha = score; //score we report to the gui
:
Regards
Dan H.
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.