- && !moveIsCapture
- && !move_is_promotion(move)
- && moveCount >= 2 + int(sp->depth)
- && ok_to_prune(pos, move, ss[sp->ply].threatMove, sp->depth))
- continue;
+ && !captureOrPromotion)
+ {
+ // History pruning. See ok_to_prune() definition
+ if ( moveCount >= 2 + int(sp->depth)
+ && ok_to_prune(pos, move, ss[sp->ply].threatMove, sp->depth)
+ && sp->bestValue > value_mated_in(PLY_MAX))
+ continue;
+
+ // Value based pruning
+ if (sp->approximateEval < sp->beta)
+ {
+ if (sp->futilityValue == VALUE_NONE)
+ {
+ EvalInfo ei;
+ sp->futilityValue = evaluate(pos, ei, threadID)
+ + FutilityMargins[int(sp->depth) - 2];
+ }
+
+ if (sp->futilityValue < sp->beta)
+ {
+ if (sp->futilityValue > sp->bestValue) // Less then 1% of cases
+ {
+ lock_grab(&(sp->lock));
+ if (sp->futilityValue > sp->bestValue)
+ sp->bestValue = sp->futilityValue;
+ lock_release(&(sp->lock));
+ }
+ continue;
+ }
+ }
+ }