Shortcut futility pruning in qsearch

If we have pruned one capture due to its final value
we can prune also following ones because captures are
MVV ordered.

Also avoid a compare when not in PV because in that
case is always false.

No functional change.
This commit is contained in:
Marco Costalba
2010-06-03 12:10:12 +02:00
parent ab127028ed
commit 5f3c660d5d

View File

@@ -1467,12 +1467,13 @@ namespace {
EvalInfo ei; EvalInfo ei;
StateInfo st; StateInfo st;
Move ttMove, move; Move ttMove, move;
Value staticValue, bestValue, value, futilityBase, futilityValue; Value staticValue, bestValue, value, futilityBase;
bool isCheck, enoughMaterial, moveIsCheck, evasionPrunable; bool isCheck, enoughMaterial, moveIsCheck, evasionPrunable;
const TTEntry* tte = NULL; const TTEntry* tte = NULL;
int moveCount = 0; int moveCount = 0;
int ply = pos.ply(); int ply = pos.ply();
Value oldAlpha = alpha; Value oldAlpha = alpha;
Value futilityValue = VALUE_INFINITE;
TM.incrementNodeCounter(pos.thread()); TM.incrementNodeCounter(pos.thread());
ss->init(ply); ss->init(ply);
@@ -1524,7 +1525,7 @@ namespace {
return bestValue; return bestValue;
} }
if (bestValue > alpha) if (PvNode && bestValue > alpha)
alpha = bestValue; alpha = bestValue;
// If we are near beta then try to get a cutoff pushing checks a bit further // If we are near beta then try to get a cutoff pushing checks a bit further
@@ -1560,6 +1561,11 @@ namespace {
&& !move_is_promotion(move) && !move_is_promotion(move)
&& !pos.move_is_passed_pawn_push(move)) && !pos.move_is_passed_pawn_push(move))
{ {
// Can only decrease from previous move because of
// MVV ordering so we don't need to recheck.
if (futilityValue < alpha)
continue;
futilityValue = futilityBase futilityValue = futilityBase
+ pos.endgame_value_of_piece_on(move_to(move)) + pos.endgame_value_of_piece_on(move_to(move))
+ (move_is_ep(move) ? PawnValueEndgame : Value(0)); + (move_is_ep(move) ? PawnValueEndgame : Value(0));