]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Remove pointless tte->static_value() != VALUE_NONE checks
[stockfish] / src / search.cpp
index 7aab835d93d36a7b7eba9db7479ca5a1716cd3af..48c06fd3c56c29179572c0b56eb339c1973d06c1 100644 (file)
@@ -760,7 +760,9 @@ namespace {
     beta = *betaPtr;
     isCheck = pos.is_check();
 
-    // Step 1. Initialize node and poll (omitted at root, init_ss_array() has already initialized root node)
+    // Step 1. Initialize node (polling is omitted at root)
+    ss->init();
+
     // Step 2. Check for aborted search (omitted at root)
     // Step 3. Mate distance pruning (omitted at root)
     // Step 4. Transposition table lookup (omitted at root)
@@ -1081,8 +1083,9 @@ namespace {
     isCheck = pos.is_check();
     if (!isCheck)
     {
-        if (tte && tte->static_value() != VALUE_NONE)
+        if (tte)
         {
+            assert(tte->static_value() != VALUE_NONE);
             ss->eval = tte->static_value();
             ei.kingDanger[pos.side_to_move()] = tte->king_danger();
         }
@@ -1106,7 +1109,7 @@ namespace {
         && !pos.has_pawn_on_7th(pos.side_to_move()))
     {
         // Pass ss->eval to qsearch() and avoid an evaluate call
-        if (!tte || tte->static_value() == VALUE_NONE)
+        if (!tte)
             TT.store(posKey, ss->eval, VALUE_TYPE_EXACT, Depth(-127*OnePly), MOVE_NONE, ss->eval, ei.kingDanger[pos.side_to_move()]);
 
         Value rbeta = beta - razor_margin(depth);
@@ -1474,8 +1477,9 @@ namespace {
     }
     else
     {
-        if (tte && tte->static_value() != VALUE_NONE)
+        if (tte)
         {
+            assert(tte->static_value() != VALUE_NONE);
             ei.kingDanger[pos.side_to_move()] = tte->king_danger();
             bestValue = tte->static_value();
         }
@@ -2208,10 +2212,7 @@ namespace {
         ss->reduction = Depth(0);
 
         if (i < 3)
-        {
-            ss->init();
             ss->initKillers();
-        }
     }
   }
 
@@ -2731,6 +2732,11 @@ namespace {
     StateInfo st;
     bool includeAllMoves = (searchMoves[0] == MOVE_NONE);
 
+    // Initialize search stack
+    init_ss_array(ss, PLY_MAX_PLUS_2);
+    ss[0].init();
+    ss[0].eval = VALUE_NONE;
+
     // Generate all legal moves
     MoveStack* last = generate_moves(pos, mlist);
 
@@ -2746,10 +2752,8 @@ namespace {
             continue;
 
         // Find a quick score for the move
-        init_ss_array(ss, PLY_MAX_PLUS_2);
-        ss[0].eval = VALUE_NONE;
-        ss[0].currentMove = cur->move;
         pos.do_move(cur->move, st);
+        ss[0].currentMove = cur->move;
         moves[count].move = cur->move;
         moves[count].score = -qsearch<PV>(pos, ss+1, -VALUE_INFINITE, VALUE_INFINITE, Depth(0), 1);
         moves[count].pv[0] = cur->move;