X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=1101a41ed69e046561bdb18d61284af587ed613f;hp=a7dbd90d522608b992679ec283d64c80bc197f40;hb=a753e20bd4fc1e916f7e99884c01bb63fd7c1326;hpb=9f8f093fd63f612ff28ca8b4812d0701f6d64ea7 diff --git a/src/search.cpp b/src/search.cpp index a7dbd90d..1101a41e 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -75,6 +75,12 @@ namespace { return Reductions[PvNode][i][std::min(d / ONE_PLY, 63)][std::min(mn, 63)] * ONE_PLY; } + // History and stats update bonus, based on depth + Value stat_bonus(Depth depth) { + int d = depth / ONE_PLY ; + return Value(d * d + 2 * d - 2); + } + // Skill structure is used to implement strength limit struct Skill { Skill(int l) : level(l) {} @@ -155,9 +161,6 @@ namespace { const size_t HalfDensitySize = std::extent::value; - Value bonus(Depth depth) { int d = depth / ONE_PLY ; return Value(d * d + 2 * d - 2); } - Value penalty(Depth depth) { int d = depth / ONE_PLY ; return -Value(d * d + 4 * d + 1); } - EasyMoveManager EasyMove; Value DrawValue[COLOR_NB]; @@ -502,7 +505,7 @@ void Thread::search() { bool doEasyMove = rootMoves[0].pv[0] == easyMove && mainThread->bestMoveChanges < 0.03 - && Time.elapsed() > Time.optimum() * 5 / 42; + && Time.elapsed() > Time.optimum() * 5 / 44; if ( rootMoves.size() == 1 || Time.elapsed() > Time.optimum() * unstablePvFactor * improvingFactor / 628 @@ -642,14 +645,24 @@ namespace { : (tte->bound() & BOUND_UPPER))) { // If ttMove is quiet, update move sorting heuristics on TT hit - if (ttValue >= beta && ttMove) + if (ttMove) { - if (!pos.capture_or_promotion(ttMove)) - update_stats(pos, ss, ttMove, nullptr, 0, bonus(depth)); + if (ttValue >= beta) + { + if (!pos.capture_or_promotion(ttMove)) + update_stats(pos, ss, ttMove, nullptr, 0, stat_bonus(depth)); - // Extra penalty for a quiet TT move in previous ply when it gets refuted - if ((ss-1)->moveCount == 1 && !pos.captured_piece()) - update_cm_stats(ss-1, pos.piece_on(prevSq), prevSq, penalty(depth)); + // Extra penalty for a quiet TT move in previous ply when it gets refuted + if ((ss-1)->moveCount == 1 && !pos.captured_piece()) + update_cm_stats(ss-1, pos.piece_on(prevSq), prevSq, -stat_bonus(depth + ONE_PLY)); + } + // Penalty for a quiet ttMove that fails low + else if (!pos.capture_or_promotion(ttMove)) + { + Value penalty = -stat_bonus(depth + ONE_PLY); + thisThread->history.update(pos.side_to_move(), ttMove, penalty); + update_cm_stats(ss, pos.moved_piece(ttMove), to_sq(ttMove), penalty); + } } return ttValue; } @@ -988,7 +1001,7 @@ moves_loop: // When in check search starts from here + (fmh ? (*fmh )[moved_piece][to_sq(move)] : VALUE_ZERO) + (fmh2 ? (*fmh2)[moved_piece][to_sq(move)] : VALUE_ZERO) + thisThread->history.get(~pos.side_to_move(), move) - - 8000; // Correction factor + - 4000; // Correction factor // Decrease/increase reduction by comparing opponent's stat score if (ss->history > VALUE_ZERO && (ss-1)->history < VALUE_ZERO) @@ -1120,17 +1133,17 @@ moves_loop: // When in check search starts from here // Quiet best move: update move sorting heuristics if (!pos.capture_or_promotion(bestMove)) - update_stats(pos, ss, bestMove, quietsSearched, quietCount, bonus(depth)); + update_stats(pos, ss, bestMove, quietsSearched, quietCount, stat_bonus(depth)); // Extra penalty for a quiet TT move in previous ply when it gets refuted if ((ss-1)->moveCount == 1 && !pos.captured_piece()) - update_cm_stats(ss-1, pos.piece_on(prevSq), prevSq, penalty(depth)); + update_cm_stats(ss-1, pos.piece_on(prevSq), prevSq, -stat_bonus(depth + ONE_PLY)); } // Bonus for prior countermove that caused the fail low else if ( depth >= 3 * ONE_PLY && !pos.captured_piece() && is_ok((ss-1)->currentMove)) - update_cm_stats(ss-1, pos.piece_on(prevSq), prevSq, bonus(depth)); + update_cm_stats(ss-1, pos.piece_on(prevSq), prevSq, stat_bonus(depth)); tte->save(posKey, value_to_tt(bestValue, ss->ply), bestValue >= beta ? BOUND_LOWER :