X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=756b2d5769fb6f44b854cad829f9e1b1242746ef;hp=7876f9314ad93e56242c569e0f79a26e0c7a5498;hb=ae5d2c38e1b9f6a990c29d31a37d6555d197f939;hpb=4f3804f3f39e573a24ece662cbf79fe30368ff1e diff --git a/src/search.cpp b/src/search.cpp index 7876f931..756b2d57 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -254,7 +254,7 @@ void MainThread::search() { && !Skill(Options["Skill Level"]).enabled() && rootMoves[0].pv[0] != MOVE_NONE) { - std::map votes; + std::map votes; Value minScore = this->rootMoves[0].score; // Find out minimum score and reset votes for moves which can be voted @@ -265,12 +265,13 @@ void MainThread::search() { } // Vote according to score and depth + auto square = [](int64_t x) { return x * x; }; for (Thread* th : Threads) - votes[th->rootMoves[0].pv[0]] += int(th->rootMoves[0].score - minScore) - + int(th->completedDepth); + votes[th->rootMoves[0].pv[0]] += 200 + (square(th->rootMoves[0].score - minScore + 1) + * int64_t(th->completedDepth)); // Select best thread - int bestVote = votes[this->rootMoves[0].pv[0]]; + int64_t bestVote = votes[this->rootMoves[0].pv[0]]; for (Thread* th : Threads) { if (votes[th->rootMoves[0].pv[0]] > bestVote) @@ -303,6 +304,7 @@ void MainThread::search() { void Thread::search() { Stack stack[MAX_PLY+7], *ss = stack+4; // To reference from (ss-4) to (ss+2) + Move pv[MAX_PLY+1]; Value bestValue, alpha, beta, delta; Move lastBestMove = MOVE_NONE; Depth lastBestMoveDepth = DEPTH_ZERO; @@ -314,6 +316,7 @@ void Thread::search() { std::memset(ss-4, 0, 7 * sizeof(Stack)); for (int i = 4; i > 0; i--) (ss-i)->continuationHistory = &this->continuationHistory[NO_PIECE][0]; // Use as sentinel + ss->pv = pv; bestValue = delta = alpha = -VALUE_INFINITE; beta = VALUE_INFINITE; @@ -653,9 +656,11 @@ namespace { if (!pos.capture_or_promotion(ttMove)) update_quiet_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_continuation_histories(ss-1, pos.piece_on(prevSq), prevSq, -stat_bonus(depth + ONE_PLY)); + // Extra penalty for a quiet TT or main killer move in previous ply when it gets refuted + if ( (ss-1)->moveCount == 1 + || ((ss-1)->currentMove == (ss-1)->killers[0] && (ss-1)->killers[0])) + if (!pos.captured_piece()) + update_continuation_histories(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)) @@ -756,8 +761,9 @@ namespace { } // Step 7. Razoring (~2 Elo) - if ( depth < 2 * ONE_PLY - && eval <= alpha - RazorMargin) + if ( !rootNode // The required rootNode PV handling is not available in qsearch + && depth < 2 * ONE_PLY + && eval <= alpha - RazorMargin) return qsearch(pos, ss, alpha, beta); improving = ss->staticEval >= (ss-2)->staticEval