]> git.sesse.net Git - stockfish/commitdiff
Clean up repetitive declarations for see_ge
authorMiguel Lahoz <miguel_lahoz@protonmail.com>
Mon, 27 Mar 2023 16:06:24 +0000 (00:06 +0800)
committerJoost VandeVondele <Joost.VandeVondele@gmail.com>
Wed, 29 Mar 2023 19:43:07 +0000 (21:43 +0200)
The occupied bitboard is only used in one place and is otherwise thrown away.
To simplify use, see_ge function can instead be overloaded.
Repetitive declarations for occupied bitboard can be removed.

Passed non-regression test
https://tests.stockfishchess.org/tests/view/6421c286db43ab2ba6f908eb
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 48912 W: 13196 L: 13001 D: 22715
Ptnml(0-2): 146, 5003, 13967, 5190, 150

closes https://github.com/official-stockfish/Stockfish/pull/4469

No functional change.

src/movepick.cpp
src/movepick.h
src/position.cpp
src/position.h
src/search.cpp

index 855f2b1d67dbf916456f4af71ce909eb7aac6859..36ee46b50f08302a52e2fc22b6aff8a03c887cd8 100644 (file)
@@ -95,7 +95,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Value th, const CapturePiece
 
   stage = PROBCUT_TT + !(ttm && pos.capture_stage(ttm)
                              && pos.pseudo_legal(ttm)
-                             && pos.see_ge(ttm, occupied, threshold));
+                             && pos.see_ge(ttm, threshold));
 }
 
 /// MovePicker::score() assigns a numerical value to each move in a list, used
@@ -197,7 +197,7 @@ top:
 
   case GOOD_CAPTURE:
       if (select<Next>([&](){
-                       return pos.see_ge(*cur, occupied, Value(-cur->value)) ?
+                       return pos.see_ge(*cur, Value(-cur->value)) ?
                               // Move losing capture to endBadCaptures to be tried later
                               true : (*endBadCaptures++ = *cur, false); }))
           return *(cur - 1);
@@ -264,7 +264,7 @@ top:
       return select<Best>([](){ return true; });
 
   case PROBCUT:
-      return select<Next>([&](){ return pos.see_ge(*cur, occupied, threshold); });
+      return select<Next>([&](){ return pos.see_ge(*cur, threshold); });
 
   case QCAPTURE:
       if (select<Next>([&](){ return   depth > DEPTH_QS_RECAPTURES
index 725607b8a54c2d873f4dd75faa9294357407afb4..b6c073782408e9b730bd8bd2c006f748ec4c1a29 100644 (file)
@@ -150,7 +150,6 @@ private:
   Value threshold;
   Depth depth;
   ExtMove moves[MAX_MOVES];
-  Bitboard occupied;
 };
 
 } // namespace Stockfish
index ba6888eb9489662cc4746726e9c04f2a6de0414e..e6fdb511fcc10a03f11ab3eb72fd79917f52d96e 100644 (file)
@@ -1163,6 +1163,11 @@ bool Position::see_ge(Move m, Bitboard& occupied, Value threshold) const {
   return bool(res);
 }
 
+bool Position::see_ge(Move m, Value threshold) const {
+    Bitboard occupied;
+    return see_ge(m, occupied, threshold);
+}
+
 
 /// Position::is_draw() tests whether the position is drawn by 50-move rule
 /// or by repetition. It does not detect stalemates.
index 670b621ce7452b8b7491da4ce8ed065307eb95d7..bb45c44a3bf97e24f7507109acc9dce761b9cd48 100644 (file)
@@ -145,6 +145,7 @@ public:
 
   // Static Exchange Evaluation
   bool see_ge(Move m, Bitboard& occupied, Value threshold = VALUE_ZERO) const;
+  bool see_ge(Move m, Value threshold = VALUE_ZERO) const;
 
   // Accessing hash keys
   Key key() const;
index d2358ea2e1c2d9ccf1507947d87d9d85192e5e33..ac74cdaf885e5574b0ccf8c2030934e4cad14f48 100644 (file)
@@ -1058,9 +1058,8 @@ moves_loop: // When in check, search starts here
 
               lmrDepth = std::max(lmrDepth, 0);
 
-              Bitboard occupied;
               // Prune moves with negative SEE (~4 Elo)
-              if (!pos.see_ge(move, occupied, Value(-24 * lmrDepth * lmrDepth - 15 * lmrDepth)))
+              if (!pos.see_ge(move, Value(-24 * lmrDepth * lmrDepth - 15 * lmrDepth)))
                   continue;
           }
       }
@@ -1545,7 +1544,6 @@ moves_loop: // When in check, search starts here
                                       prevSq);
 
     int quietCheckEvasions = 0;
-    Bitboard occupied;
 
     // Step 5. Loop through all pseudo-legal moves until no moves remain
     // or a beta cutoff occurs.
@@ -1582,7 +1580,7 @@ moves_loop: // When in check, search starts here
               continue;
           }
 
-          if (futilityBase <= alpha && !pos.see_ge(move, occupied, VALUE_ZERO + 1))
+          if (futilityBase <= alpha && !pos.see_ge(move, VALUE_ZERO + 1))
           {
               bestValue = std::max(bestValue, futilityBase);
               continue;
@@ -1601,7 +1599,7 @@ moves_loop: // When in check, search starts here
           continue;
 
       // Do not search moves with bad enough SEE values (~5 Elo)
-      if (!pos.see_ge(move, occupied, Value(-110)))
+      if (!pos.see_ge(move, Value(-110)))
           continue;
     }