- // 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))
+ // 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]];