@@ -84,11 +84,10 @@ namespace {
8484 return d > 17 ? 0 : 29 * d * d + 138 * d - 134 ;
8585 }
8686
87- // Add a small random component to draw evaluations to keep search dynamic
88- // and to avoid 3fold-blindness.
87+ // Add a small random component to draw evaluations to avoid 3fold-blindness
8988 Value value_draw (Depth depth, Thread* thisThread) {
9089 return depth < 4 ? VALUE_DRAW
91- : VALUE_DRAW + Value (2 * (thisThread->nodes . load (std::memory_order_relaxed) % 2 ) - 1 );
90+ : VALUE_DRAW + Value (2 * (thisThread->nodes & 1 ) - 1 );
9291 }
9392
9493 // Skill structure is used to implement strength limit
@@ -162,12 +161,12 @@ void Search::clear() {
162161 Time.availableNodes = 0 ;
163162 TT.clear ();
164163 Threads.clear ();
165- Tablebases::init (Options[" SyzygyPath" ]); // Free up mapped files
164+ Tablebases::init (Options[" SyzygyPath" ]); // Free mapped files
166165}
167166
168167
169- // / MainThread::search() is called by the main thread when the program receives
170- // / the UCI 'go' command. It searches from the root position and outputs the "bestmove".
168+ // / MainThread::search() is started when the program receives the UCI 'go'
169+ // / command. It searches from the root position and outputs the "bestmove".
171170
172171void MainThread::search () {
173172
@@ -221,8 +220,9 @@ void MainThread::search() {
221220 if (Limits.npmsec )
222221 Time.availableNodes += Limits.inc [us] - Threads.nodes_searched ();
223222
224- // Check if there are threads with a better score than main thread
225223 Thread* bestThread = this ;
224+
225+ // Check if there are threads with a better score than main thread
226226 if ( Options[" MultiPV" ] == 1
227227 && !Limits.depth
228228 && !Skill (Options[" Skill Level" ]).enabled ()
@@ -273,9 +273,9 @@ void MainThread::search() {
273273
274274void Thread::search () {
275275
276- // To allow access to (ss-5 ) up to (ss+2), the stack must be oversized.
276+ // To allow access to (ss-7 ) up to (ss+2), the stack must be oversized.
277277 // The former is needed to allow update_continuation_histories(ss-1, ...),
278- // which accesses its argument at ss-4 , also near the root.
278+ // which accesses its argument at ss-6 , also near the root.
279279 // The latter is needed for statScores and killer initialization.
280280 Stack stack[MAX_PLY+10 ], *ss = stack+7 ;
281281 Move pv[MAX_PLY+1 ];
@@ -317,7 +317,7 @@ void Thread::search() {
317317 : Options[" Analysis Contempt" ] == " Black" && us == WHITE ? -ct
318318 : ct;
319319
320- // In evaluate.cpp the evaluation is from the white point of view
320+ // Evaluation score is from the white point of view
321321 contempt = (us == WHITE ? make_score (ct, ct / 2 )
322322 : -make_score (ct, ct / 2 ));
323323
@@ -832,8 +832,7 @@ namespace {
832832 }
833833
834834 // Step 11. Internal iterative deepening (~2 Elo)
835- if ( depth >= 8 * ONE_PLY
836- && !ttMove)
835+ if (depth >= 8 * ONE_PLY && !ttMove)
837836 {
838837 search<NT>(pos, ss, alpha, beta, depth - 7 * ONE_PLY, cutNode);
839838
@@ -847,15 +846,16 @@ namespace {
847846 const PieceToHistory* contHist[] = { (ss-1 )->continuationHistory , (ss-2 )->continuationHistory ,
848847 nullptr , (ss-4 )->continuationHistory ,
849848 nullptr , (ss-6 )->continuationHistory };
849+
850850 Move countermove = thisThread->counterMoves [pos.piece_on (prevSq)][prevSq];
851851
852852 MovePicker mp (pos, ttMove, depth, &thisThread->mainHistory ,
853853 &thisThread->captureHistory ,
854854 contHist,
855855 countermove,
856856 ss->killers );
857- value = bestValue; // Workaround a bogus 'uninitialized' warning under gcc
858857
858+ value = bestValue; // Workaround a bogus 'uninitialized' warning under gcc
859859 moveCountPruning = false ;
860860 ttCapture = ttMove && pos.capture_or_promotion (ttMove);
861861
@@ -946,7 +946,7 @@ namespace {
946946 && bestValue > VALUE_MATED_IN_MAX_PLY)
947947 {
948948 // Skip quiet moves if movecount exceeds our FutilityMoveCount threshold
949- moveCountPruning = moveCount >= futility_move_count (improving,depth / ONE_PLY);
949+ moveCountPruning = moveCount >= futility_move_count (improving, depth / ONE_PLY);
950950
951951 if ( !captureOrPromotion
952952 && !givesCheck
0 commit comments