X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=f0783363e79766fc682dabbf42fc4d0d0cda9469;hp=7a8d3253048d2db2d7595493cb242692970f6d57;hb=f2681232e516da164196d7238482729da038ae1e;hpb=62937d1007e0f97e629f376adca4f4ad738e95d1 diff --git a/src/search.cpp b/src/search.cpp index 7a8d3253..f0783363 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -72,6 +72,16 @@ namespace { return Value((175 - 50 * improving) * d / ONE_PLY); } + // Margin for pruning capturing moves: almost linear in depth + constexpr int CapturePruneMargin[] = { 0, + 1 * PawnValueEg * 1055 / 1000, + 2 * PawnValueEg * 1042 / 1000, + 3 * PawnValueEg * 963 / 1000, + 4 * PawnValueEg * 1038 / 1000, + 5 * PawnValueEg * 950 / 1000, + 6 * PawnValueEg * 930 / 1000 + }; + // Futility and reductions lookup tables, initialized at startup int FutilityMoveCounts[2][16]; // [improving][depth] int Reductions[2][2][64][64]; // [pv][improving][depth][moveNumber] @@ -160,7 +170,7 @@ void Search::init() { Reductions[PV][imp][d][mc] = std::max(Reductions[NonPV][imp][d][mc] - 1, 0); // Increase reduction for non-PV nodes when eval is not improving - if (!imp && Reductions[NonPV][imp][d][mc] >= 2) + if (!imp && r > 1.0) Reductions[NonPV][imp][d][mc]++; } @@ -309,8 +319,8 @@ void Thread::search() { multiPV = std::min(multiPV, rootMoves.size()); int ct = Options["Contempt"] * PawnValueEg / 100; // From centipawns - Eval::Contempt = (us == WHITE ? make_score(ct, ct / 2) - : -make_score(ct, ct / 2)); + contempt = (us == WHITE ? make_score(ct, ct / 2) + : -make_score(ct, ct / 2)); // Iterative deepening loop until requested to stop or the target depth is reached while ( (rootDepth += ONE_PLY) < DEPTH_MAX @@ -343,17 +353,18 @@ void Thread::search() { // Reset aspiration window starting size if (rootDepth >= 5 * ONE_PLY) { + Value previousScore = rootMoves[PVIdx].previousScore; delta = Value(18); - alpha = std::max(rootMoves[PVIdx].previousScore - delta,-VALUE_INFINITE); - beta = std::min(rootMoves[PVIdx].previousScore + delta, VALUE_INFINITE); + alpha = std::max(previousScore - delta,-VALUE_INFINITE); + beta = std::min(previousScore + delta, VALUE_INFINITE); ct = Options["Contempt"] * PawnValueEg / 100; // From centipawns - // Adjust contempt based on current bestValue (dynamic contempt) - ct += int(std::round(48 * atan(float(bestValue) / 128))); + // Adjust contempt based on root move's previousScore (dynamic contempt) + ct += int(std::round(48 * atan(float(previousScore) / 128))); - Eval::Contempt = (us == WHITE ? make_score(ct, ct / 2) - : -make_score(ct, ct / 2)); + contempt = (us == WHITE ? make_score(ct, ct / 2) + : -make_score(ct, ct / 2)); } // Start with a small aspiration window and, in the case of a fail @@ -918,7 +929,7 @@ moves_loop: // When in check, search starts from here } else if ( depth < 7 * ONE_PLY && !extension - && !pos.see_ge(move, -PawnValueEg * (depth / ONE_PLY))) + && !pos.see_ge(move, -Value(CapturePruneMargin[depth / ONE_PLY]))) continue; } @@ -1495,7 +1506,7 @@ void MainThread::check_time() { static TimePoint lastInfoTime = now(); - int elapsed = Time.elapsed(); + TimePoint elapsed = Time.elapsed(); TimePoint tick = Limits.startTime + elapsed; if (tick - lastInfoTime >= 1000) @@ -1521,7 +1532,7 @@ void MainThread::check_time() { string UCI::pv(const Position& pos, Depth depth, Value alpha, Value beta) { std::stringstream ss; - int elapsed = Time.elapsed() + 1; + TimePoint elapsed = Time.elapsed() + 1; const RootMoves& rootMoves = pos.this_thread()->rootMoves; size_t PVIdx = pos.this_thread()->PVIdx; size_t multiPV = std::min((size_t)Options["MultiPV"], rootMoves.size());