- // Evaluate the position statically:
- Value staticValue = evaluate(pos, ei, threadID);
+ return value_from_tt(tte->value(), ply);
+ }
+ }
+
+ // Evaluate the position statically
+ EvalInfo ei;
+ Value staticValue;
+ bool isCheck = pos.is_check();
+ ei.futilityMargin = Value(0); // Manually initialize futilityMargin
+
+ if (isCheck)
+ staticValue = -VALUE_INFINITE;
+
+ else if (tte && tte->type() == VALUE_TYPE_EVAL)
+ {
+ // Use the cached evaluation score if possible
+ assert(tte->value() == evaluate(pos, ei, threadID));
+ assert(ei.futilityMargin == Value(0));
+
+ staticValue = tte->value();
+ }
+ else
+ staticValue = evaluate(pos, ei, threadID);