I'm currently pondering when it's best to quit the search to be able to use the results of the current search without trouble.
The scenario is like this: We search to a (slightly flexible) timelimit. The search started a new iteration but runs out of time. But we want to use the current information searched on this iteration. What do we do?
I'm thinking that if the search didn't find a best move yet, it's probably best to delay the quitting (if possible) or not use the information for the current iteration and stick with the previous iterations. When we completed to search the PV at the current iteration, we can safely quit and use the new score and PV. Is my thinking correct?
I usually test to quit the search after checking for fail high and updating the PV:
Code: Select all
// Check for a fail high
if (score >= beta)
return beta;
// Check if we have a new best move
if (score > alpha)
{
alpha = score;
foundPV = true;
searcher->mPVline[ply][ply] = cmove;
int c;
for (c = ply+1; searcher->mPVline[ply+1][c] != 0; c++)
searcher->mPVline[ply][c] = searcher->mPVline[ply+1][c];
searcher->mPVline[ply][c] = 0;
}
--> // Check if we should abort the search
if (crew->mSCStopSearch == true)
return alpha;
Code: Select all
// Check if we should abort the search
if (crew->mSCStopSearch == true && foundPV == true)
return alpha;