X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=e3030490863f4289df4439ce287a4306bc297262;hp=856c003a3654f758f44cc5523264fb84910255d7;hb=10184748533195e4a76a7283b9f9048db05c6fc4;hpb=eb1a4f11fa18d22543bef9a507d57a5980867965 diff --git a/src/search.cpp b/src/search.cpp index 856c003a..e3030490 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -136,7 +136,7 @@ void Search::init() { // Init futility move count array for (d = 0; d < 32; d++) - FutilityMoveCounts[d] = int(3.001 + 0.25 * pow(d, 2.0)); + FutilityMoveCounts[d] = int(3.001 + 0.25 * pow(double(d), 2.0)); } @@ -557,6 +557,8 @@ namespace { : 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 @@ -574,6 +576,7 @@ namespace { // 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); @@ -818,6 +821,8 @@ split_point_start: // At split points actual search starts from here && 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; @@ -1111,6 +1116,8 @@ split_point_start: // At split points actual search starts from here : 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; } @@ -1368,13 +1375,10 @@ split_point_start: // At split points actual search starts from here 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; } @@ -1384,13 +1388,9 @@ split_point_start: // At split points actual search starts from here 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; } @@ -1435,11 +1435,13 @@ split_point_start: // At split points actual search starts from here // 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))