+ // Calculate depth dependant futility pruning parameters
+ const int FutilityMoveCountMargin = 3 + (1 << (3 * int(depth) / 8));
+ const int PostFutilityValueMargin = 112 * bitScanReverse32(int(depth) * int(depth) / 2);
+
+ // Evaluate the position statically
+ if (!isCheck)
+ {
+ if (tte && (tte->type() & VALUE_TYPE_EVAL))
+ staticValue = value_from_tt(tte->value(), ply);
+ else
+ {
+ staticValue = evaluate(pos, ei, threadID);
+ ss[ply].evalInfo = &ei;
+ }
+
+ ss[ply].eval = staticValue;
+ futilityValue = staticValue + PostFutilityValueMargin; //FIXME: Remove me, only for split
+ staticValue = refine_eval(tte, staticValue, ply); // Enhance accuracy with TT value if possible
+ update_gains(pos, ss[ply - 1].currentMove, ss[ply - 1].eval, ss[ply].eval);
+ }
+
+ // Do a "stand pat". If we are above beta by a good margin then
+ // return immediately.
+ // FIXME: test with added condition 'allowNullmove || depth <= OnePly' and !value_is_mate(beta)
+ // FIXME: test with modified condition 'depth < RazorDepth'
+ if ( !isCheck
+ && depth < SelectiveDepth
+ && staticValue - PostFutilityValueMargin >= beta)
+ return staticValue - PostFutilityValueMargin;
+