]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Don't allow LMR to fall in qsearch
[stockfish] / src / search.cpp
index 48cb4d6bdd9df3a36bacff4d04b3ce0dfd5dac34..3ec60e7cfd4f3d768631ab3a80d2e66f1adcff80 100644 (file)
@@ -249,7 +249,6 @@ void Search::think() {
 
   static Book book; // Defined static to initialize the PRNG only once
 
-  Move bm;
   Position& pos = RootPosition;
   Chess960 = pos.is_chess960();
   elapsed_time(true);
@@ -266,12 +265,15 @@ void Search::think() {
       goto finalize;
   }
 
-  if (   Options["OwnBook"]
-      && (bm = book.probe(pos, Options["Book File"], Options["Best Book Move"])) != MOVE_NONE
-      && count(RootMoves.begin(), RootMoves.end(), bm))
+  if (Options["OwnBook"])
   {
-      std::swap(RootMoves[0], *find(RootMoves.begin(), RootMoves.end(), bm));
-      goto finalize;
+      Move bookMove = book.probe(pos, Options["Book File"], Options["Best Book Move"]);
+
+      if (bookMove && count(RootMoves.begin(), RootMoves.end(), bookMove))
+      {
+          std::swap(RootMoves[0], *find(RootMoves.begin(), RootMoves.end(), bookMove));
+          goto finalize;
+      }
   }
 
   // Read UCI options: GUI could change UCI parameters during the game
@@ -964,7 +966,7 @@ split_point_start: // At split points actual search starts from here
 
       // Step 15. Reduced depth search (LMR). If the move fails high will be
       // re-searched at full depth.
-      if (   depth > 3 * ONE_PLY
+      if (   depth > 4 * ONE_PLY
           && !isPvMove
           && !captureOrPromotion
           && !dangerous
@@ -973,11 +975,10 @@ split_point_start: // At split points actual search starts from here
           &&  ss->killers[1] != move)
       {
           ss->reduction = reduction<PvNode>(depth, moveCount);
-          Depth d = newDepth - ss->reduction;
+          Depth d = std::max(newDepth - ss->reduction, ONE_PLY);
           alpha = SpNode ? sp->alpha : alpha;
 
-          value = d < ONE_PLY ? -qsearch<NonPV>(pos, ss+1, -(alpha+1), -alpha, DEPTH_ZERO)
-                              : - search<NonPV>(pos, ss+1, -(alpha+1), -alpha, d);
+          value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, d);
 
           doFullDepthSearch = (value > alpha && ss->reduction != DEPTH_ZERO);
           ss->reduction = DEPTH_ZERO;