- // Set up improving flag that is used in various pruning heuristics
- // We define position as improving if static evaluation of position is better
- // Than the previous static evaluation at our turn
- // In case of us being in check at our previous move we look at move prior to it
- improving = (ss-2)->staticEval == VALUE_NONE
- ? ss->staticEval > (ss-4)->staticEval || (ss-4)->staticEval == VALUE_NONE
- : ss->staticEval > (ss-2)->staticEval;
+ // Set up the improvement variable, which is the difference between the current
+ // static evaluation and the previous static evaluation at our turn (if we were
+ // in check at our previous move we look at the move prior to it). The improvement
+ // margin and the improving flag are used in various pruning heuristics.
+ improvement = (ss-2)->staticEval != VALUE_NONE ? ss->staticEval - (ss-2)->staticEval
+ : (ss-4)->staticEval != VALUE_NONE ? ss->staticEval - (ss-4)->staticEval
+ : 156;
+ improving = improvement > 0;
+
+ // Step 7. Razoring (~1 Elo).
+ // If eval is really low check with qsearch if it can exceed alpha, if it can't,
+ // return a fail low.
+ if (eval < alpha - 426 - 252 * depth * depth)
+ {
+ value = qsearch<NonPV>(pos, ss, alpha - 1, alpha);
+ if (value < alpha)
+ return value;
+ }