X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=990c4123e6a91659ed0ab94baaca28a01ad8037d;hp=e36c69593e307d17aa18bf0fe9d2d60fc1b39305;hb=d96c1c32a2fa109e7cc6cd07f6029cd13977121e;hpb=571f54b176b5c30aaac35bc7bbd255c79cdcb926 diff --git a/src/search.cpp b/src/search.cpp index e36c6959..990c4123 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -246,18 +246,30 @@ void MainThread::search() { && !Skill(Options["Skill Level"]).enabled() && rootMoves[0].pv[0] != MOVE_NONE) { - for (Thread* th : Threads) - { - Depth depthDiff = th->completedDepth - bestThread->completedDepth; - Value scoreDiff = th->rootMoves[0].score - bestThread->rootMoves[0].score; + std::map votes; + Value minScore = this->rootMoves[0].score; - // Select the thread with the best score, always if it is a mate - if ( scoreDiff > 0 - && (depthDiff >= 0 || th->rootMoves[0].score >= VALUE_MATE_IN_MAX_PLY)) - bestThread = th; + // Find out minimum score and reset votes for moves which can be voted + for (Thread* th: Threads){ + minScore = std::min(minScore, th->rootMoves[0].score); + votes[th->rootMoves[0].pv[0]] = 0; + } + + // Vote according to score and depth + for (Thread* th : Threads) + votes[th->rootMoves[0].pv[0]] += int(th->rootMoves[0].score - minScore) + int(th->completedDepth); + + // Select best thread + int bestVote = votes[this->rootMoves[0].pv[0]]; + for (Thread* th : Threads){ + if (votes[th->rootMoves[0].pv[0]] > bestVote){ + bestVote = votes[th->rootMoves[0].pv[0]]; + bestThread = th; + } } } + previousScore = bestThread->rootMoves[0].score; // Send again PV info if we have a new best thread