]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Score and Select Best Thread in same loop (#2125)
[stockfish] / src / search.cpp
index fdef140026bd529a52390e8954f536eff42fa5ef..f1136e3e5b423cfaed45bae25fbc591c341690a7 100644 (file)
@@ -239,19 +239,19 @@ void MainThread::search() {
       for (Thread* th: Threads)
           minScore = std::min(minScore, th->rootMoves[0].score);
 
-      // Vote according to score and depth
+      // Vote according to score and depth, and select the best thread
+      int64_t bestVote = 0;
       for (Thread* th : Threads)
+      {
           votes[th->rootMoves[0].pv[0]] +=
                (th->rootMoves[0].score - minScore + 14) * int(th->completedDepth);
 
-      // Select best thread
-      auto 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;