Skip to content

Commit

Permalink
Retire pvMove in search()
Browse files Browse the repository at this point in the history
Now we can directly replace it with
the definition resulting in simpler
and possibly faster code because
PvNode is evaluated at compile time.

No functional change.
  • Loading branch information
mcostalba committed Nov 9, 2014
1 parent 57fdfde commit 1b0df1a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/search.cpp
Expand Up @@ -407,7 +407,7 @@ namespace {
Move ttMove, move, excludedMove, bestMove;
Depth ext, newDepth, predictedDepth;
Value bestValue, value, ttValue, eval, nullValue, futilityValue;
bool inCheck, givesCheck, pvMove, singularExtensionNode, improving;
bool inCheck, givesCheck, singularExtensionNode, improving;
bool captureOrPromotion, dangerous, doFullDepthSearch;
int moveCount, quietCount;

Expand Down Expand Up @@ -802,7 +802,6 @@ namespace {
continue;
}

pvMove = PvNode && moveCount == 1;
ss->currentMove = move;
if (!SpNode && !captureOrPromotion && quietCount < 64)
quietsSearched[quietCount++] = move;
Expand Down Expand Up @@ -851,7 +850,7 @@ namespace {
ss->reduction = DEPTH_ZERO;
}
else
doFullDepthSearch = !pvMove;
doFullDepthSearch = !PvNode || moveCount > 1;

// Step 16. Full depth search, when LMR is skipped or fails high
if (doFullDepthSearch)
Expand All @@ -868,7 +867,7 @@ namespace {
// For PV nodes only, do a full PV search on the first move or after a fail
// high (in the latter case search only if value < beta), otherwise let the
// parent node fail low with value <= alpha and to try another move.
if (PvNode && (pvMove || (value > alpha && (RootNode || value < beta))))
if (PvNode && (moveCount == 1 || (value > alpha && (RootNode || value < beta))))
value = newDepth < ONE_PLY ?
givesCheck ? -qsearch<PV, true>(pos, ss+1, -beta, -alpha, DEPTH_ZERO)
: -qsearch<PV, false>(pos, ss+1, -beta, -alpha, DEPTH_ZERO)
Expand Down Expand Up @@ -897,15 +896,15 @@ namespace {
RootMove& rm = *std::find(RootMoves.begin(), RootMoves.end(), move);

// PV move or new best move ?
if (pvMove || value > alpha)
if (moveCount == 1 || value > alpha)
{
rm.score = value;
rm.extract_pv_from_tt(pos);

// We record how often the best move has been changed in each
// iteration. This information is used for time management: When
// the best move changes frequently, we allocate some more time.
if (!pvMove)
if (moveCount > 1)
++BestMoveChanges;
}
else
Expand Down

0 comments on commit 1b0df1a

Please sign in to comment.