Skip to content

Commit

Permalink
Don't update bestValue when pruning
Browse files Browse the repository at this point in the history
Simply return a fail-low score

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
  • Loading branch information
mcostalba committed Dec 10, 2011
1 parent 14df991 commit 3f14ed6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 12 additions & 7 deletions src/search.cpp
Expand Up @@ -948,6 +948,9 @@ namespace {
{
lock_grab(&(sp->lock));
bestValue = sp->bestValue;
moveCount = sp->moveCount;

assert(bestValue > -VALUE_INFINITE && moveCount > 0);
}

// Step 11. Loop through moves
Expand Down Expand Up @@ -1065,13 +1068,7 @@ namespace {
if (futilityValue < beta)
{
if (SpNode)
{
lock_grab(&(sp->lock));
if (futilityValue > sp->bestValue)
sp->bestValue = bestValue = futilityValue;
}
else if (futilityValue > bestValue)
bestValue = futilityValue;

continue;
}
Expand Down Expand Up @@ -1220,9 +1217,17 @@ namespace {
// case of StopRequest or thread.cutoff_occurred() are set, but this is
// harmless because return value is discarded anyhow in the parent nodes.
// If we are in a singular extension search then return a fail low score.
if (!SpNode && !moveCount)
if (!moveCount)
return excludedMove ? oldAlpha : inCheck ? value_mated_in(ss->ply) : VALUE_DRAW;

// We have pruned all the moves, so return a fail-low score
if (bestValue == -VALUE_INFINITE)
{
assert(!playedMoveCount);

bestValue = alpha;
}

// Step 21. Update tables
// If the search is not aborted, update the transposition table,
// history counters, and killer moves.
Expand Down
2 changes: 1 addition & 1 deletion src/thread.cpp
Expand Up @@ -263,7 +263,7 @@ Value ThreadsManager::split(Position& pos, Stack* ss, Value alpha, Value beta,
Value bestValue, Depth depth, Move threatMove,
int moveCount, MovePicker* mp, int nodeType) {
assert(pos.pos_is_ok());
assert(bestValue >= -VALUE_INFINITE);
assert(bestValue > -VALUE_INFINITE);
assert(bestValue <= alpha);
assert(alpha < beta);
assert(beta <= VALUE_INFINITE);
Expand Down

0 comments on commit 3f14ed6

Please sign in to comment.