Simplify a condition in search()

And rearrange best value update in case of SpNode.

No functional change.
This commit is contained in:
Marco Costalba
2013-01-13 12:34:31 +01:00
parent 3a836dab59
commit 3b14b17664
+8 -11
View File
@@ -902,7 +902,7 @@ split_point_start: // At split points actual search starts from here
continue; continue;
} }
pvMove = PvNode ? moveCount == 1 : false; pvMove = PvNode && moveCount == 1;
ss->currentMove = move; ss->currentMove = move;
if (!SpNode && !captureOrPromotion && playedMoveCount < 64) if (!SpNode && !captureOrPromotion && playedMoveCount < 64)
movesSearched[playedMoveCount++] = move; movesSearched[playedMoveCount++] = move;
@@ -994,24 +994,21 @@ split_point_start: // At split points actual search starts from here
if (value > bestValue) if (value > bestValue)
{ {
bestValue = value; bestValue = SpNode ? sp->bestValue = value : value;
if (SpNode) sp->bestValue = value;
if (value > alpha) if (value > alpha)
{ {
bestMove = move; bestMove = SpNode ? sp->bestMove = move : move;
if (SpNode) sp->bestMove = move;
if (PvNode && value < beta) if (PvNode && value < beta) // Update alpha! Always alpha < beta
{ alpha = SpNode ? sp->alpha = value : value;
alpha = value; // Update alpha here! Always alpha < beta
if (SpNode) sp->alpha = value;
}
else else
{ {
assert(value >= beta); // Fail high assert(value >= beta); // Fail high
if (SpNode) sp->cutoff = true; if (SpNode)
sp->cutoff = true;
break; break;
} }
} }