: ttValue >= beta ? (tte->type() & BOUND_LOWER)
: (tte->type() & BOUND_UPPER)))
{
+ assert(ttValue != VALUE_NONE); // Due to depth > DEPTH_NONE
+
TT.refresh(tte);
ss->currentMove = ttMove; // Can be MOVE_NONE
// Step 5. Evaluate the position statically and update parent's gain statistics
if (inCheck)
ss->eval = ss->evalMargin = refinedValue = VALUE_NONE;
+
else if (tte)
{
assert(tte->static_value() != VALUE_NONE);
&& pos.pl_move_is_legal(move, ci.pinned)
&& abs(ttValue) < VALUE_KNOWN_WIN)
{
+ assert(ttValue != VALUE_NONE);
+
Value rBeta = ttValue - int(depth);
ss->excludedMove = move;
ss->skipNullMove = true;
: ttValue >= beta ? (tte->type() & BOUND_LOWER)
: (tte->type() & BOUND_UPPER)))
{
+ assert(ttValue != VALUE_NONE); // Due to ttDepth > DEPTH_NONE
+
ss->currentMove = ttMove; // Can be MOVE_NONE
return ttValue;
}
Value value_to_tt(Value v, int ply) {
- if (v >= VALUE_MATE_IN_MAX_PLY)
- return v + ply;
+ assert(v != VALUE_NONE);
- if (v <= VALUE_MATED_IN_MAX_PLY)
- return v - ply;
-
- return v;
+ return v >= VALUE_MATE_IN_MAX_PLY ? v + ply
+ : v <= VALUE_MATED_IN_MAX_PLY ? v - ply : v;
}
Value value_from_tt(Value v, int ply) {
- if (v >= VALUE_MATE_IN_MAX_PLY)
- return v - ply;
-
- if (v <= VALUE_MATED_IN_MAX_PLY)
- return v + ply;
-
- return v;
+ return v == VALUE_NONE ? VALUE_NONE
+ : v >= VALUE_MATE_IN_MAX_PLY ? v - ply
+ : v <= VALUE_MATED_IN_MAX_PLY ? v + ply : v;
}
// refine_eval() returns the transposition table score if possible, otherwise
- // falls back on static position evaluation.
+ // falls back on static position evaluation. Note that we never return VALUE_NONE
+ // even if v == VALUE_NONE.
Value refine_eval(const TTEntry* tte, Value v, Value defaultEval) {
assert(tte);
+ assert(v != VALUE_NONE || !tte->type());
if ( ((tte->type() & BOUND_LOWER) && v >= defaultEval)
|| ((tte->type() & BOUND_UPPER) && v < defaultEval))