]> git.sesse.net Git - stockfish/commitdiff
Retire mate threat extension
authorMarco Costalba <mcostalba@gmail.com>
Fri, 8 Apr 2011 06:48:05 +0000 (07:48 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Fri, 8 Apr 2011 06:48:05 +0000 (07:48 +0100)
It seems we have a lot of totally useless code !

After 8577 games 1504 - 1451 - 5622 ELO +2 (+- 4.4)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/position.cpp
src/position.h
src/search.cpp
src/thread.h
src/ucioption.cpp

index 48614fdfa14d4303e64525f02d5f789e81b3f248..f4a098d988d4e1a868d36b110b77c44d195204ff 100644 (file)
@@ -1689,46 +1689,6 @@ bool Position::is_mate() const {
 }
 
 
 }
 
 
-/// Position::has_mate_threat() tests whether the side to move is under
-/// a threat of being mated in one from the current position.
-
-bool Position::has_mate_threat() {
-
-  MoveStack mlist[MOVES_MAX], *last, *cur;
-  StateInfo st1, st2;
-  bool mateFound = false;
-
-  // If we are under check it's up to evasions to do the job
-  if (is_check())
-      return false;
-
-  // First pass the move to our opponent doing a null move
-  do_null_move(st1);
-
-  // Then generate pseudo-legal moves that could give check
-  last = generate<MV_NON_CAPTURE_CHECK>(*this, mlist);
-  last = generate<MV_CAPTURE>(*this, last);
-
-  // Loop through the moves, and see if one of them gives mate
-  Bitboard pinned = pinned_pieces(sideToMove);
-  CheckInfo ci(*this);
-  for (cur = mlist; !mateFound && cur != last; cur++)
-  {
-      Move move = cur->move;
-      if (   !pl_move_is_legal(move, pinned)
-          || !move_is_check(move, ci))
-          continue;
-
-      do_move(move, st2, ci, true);
-      mateFound = is_mate();
-      undo_move(move);
-  }
-
-  undo_null_move();
-  return mateFound;
-}
-
-
 /// Position::init_zobrist() is a static member function which initializes at
 /// startup the various arrays used to compute hash keys.
 
 /// Position::init_zobrist() is a static member function which initializes at
 /// startup the various arrays used to compute hash keys.
 
index a19911ab6035a5efb5013471e4d903b7d66e75a7..80e42aa8ff5c33536b3af1d5f854eb45b6fe60a6 100644 (file)
@@ -231,9 +231,6 @@ public:
   bool is_mate() const;
   bool is_draw() const;
 
   bool is_mate() const;
   bool is_draw() const;
 
-  // Check if side to move could be mated in one
-  bool has_mate_threat();
-
   // Number of plies from starting position
   int startpos_ply_counter() const;
 
   // Number of plies from starting position
   int startpos_ply_counter() const;
 
index 27a67a639401e3d18e48a3416a1ea4592ce1f072..80aa55cb34b8ec3c87ecd7ba079d5a54e8f0e8e3 100644 (file)
@@ -80,7 +80,7 @@ namespace {
 
     template <bool Fake>
     void split(Position& pos, SearchStack* ss, int ply, Value* alpha, const Value beta, Value* bestValue,
 
     template <bool Fake>
     void split(Position& pos, SearchStack* ss, int ply, Value* alpha, const Value beta, Value* bestValue,
-               Depth depth, Move threatMove, bool mateThreat, int moveCount, MovePicker* mp, bool pvNode);
+               Depth depth, Move threatMove, int moveCount, MovePicker* mp, bool pvNode);
 
   private:
     Depth minimumSplitDepth;
 
   private:
     Depth minimumSplitDepth;
@@ -192,8 +192,8 @@ namespace {
 
   // Extensions. Configurable UCI options
   // Array index 0 is used at non-PV nodes, index 1 at PV nodes.
 
   // Extensions. Configurable UCI options
   // Array index 0 is used at non-PV nodes, index 1 at PV nodes.
-  Depth CheckExtension[2], PawnPushTo7thExtension[2], PassedPawnExtension[2];
-  Depth PawnEndgameExtension[2], MateThreatExtension[2];
+  Depth CheckExtension[2], PawnPushTo7thExtension[2];
+  Depth PassedPawnExtension[2], PawnEndgameExtension[2];
 
   // Minimum depth for use of singular extension
   const Depth SingularExtensionDepth[2] = { 8 * ONE_PLY /* non-PV */, 6 * ONE_PLY /* PV */};
 
   // Minimum depth for use of singular extension
   const Depth SingularExtensionDepth[2] = { 8 * ONE_PLY /* non-PV */, 6 * ONE_PLY /* PV */};
@@ -280,7 +280,7 @@ namespace {
   }
 
   template <NodeType PvNode>
   }
 
   template <NodeType PvNode>
-  Depth extension(const Position& pos, Move m, bool captureOrPromotion, bool moveIsCheck, bool mateThreat, bool* dangerous);
+  Depth extension(const Position& pos, Move m, bool captureOrPromotion, bool moveIsCheck, bool* dangerous);
 
   bool check_is_dangerous(Position &pos, Move move, Value futilityBase, Value beta, Value *bValue);
   bool connected_moves(const Position& pos, Move m1, Move m2);
 
   bool check_is_dangerous(Position &pos, Move move, Value futilityBase, Value beta, Value *bValue);
   bool connected_moves(const Position& pos, Move m1, Move m2);
@@ -484,8 +484,6 @@ bool think(Position& pos, bool infinite, bool ponder, int time[], int increment[
   PassedPawnExtension[0]    = Options["Passed Pawn Extension (non-PV nodes)"].value<Depth>();
   PawnEndgameExtension[1]   = Options["Pawn Endgame Extension (PV nodes)"].value<Depth>();
   PawnEndgameExtension[0]   = Options["Pawn Endgame Extension (non-PV nodes)"].value<Depth>();
   PassedPawnExtension[0]    = Options["Passed Pawn Extension (non-PV nodes)"].value<Depth>();
   PawnEndgameExtension[1]   = Options["Pawn Endgame Extension (PV nodes)"].value<Depth>();
   PawnEndgameExtension[0]   = Options["Pawn Endgame Extension (non-PV nodes)"].value<Depth>();
-  MateThreatExtension[1]    = Options["Mate Threat Extension (PV nodes)"].value<Depth>();
-  MateThreatExtension[0]    = Options["Mate Threat Extension (non-PV nodes)"].value<Depth>();
   UCIMultiPV                = Options["MultiPV"].value<int>();
   SkillLevel                = Options["Skill level"].value<int>();
   UseLogFile                = Options["Use Search Log"].value<bool>();
   UCIMultiPV                = Options["MultiPV"].value<int>();
   SkillLevel                = Options["Skill level"].value<int>();
   UseLogFile                = Options["Use Search Log"].value<bool>();
@@ -792,7 +790,6 @@ namespace {
     Value bestValue, value, oldAlpha;
     Value refinedValue, nullValue, futilityBase, futilityValueScaled; // Non-PV specific
     bool isPvMove, isCheck, singularExtensionNode, moveIsCheck, captureOrPromotion, dangerous, isBadCap;
     Value bestValue, value, oldAlpha;
     Value refinedValue, nullValue, futilityBase, futilityValueScaled; // Non-PV specific
     bool isPvMove, isCheck, singularExtensionNode, moveIsCheck, captureOrPromotion, dangerous, isBadCap;
-    bool mateThreat = false;
     int moveCount = 0, playedMoveCount = 0;
     int threadID = pos.thread();
     SplitPoint* sp = NULL;
     int moveCount = 0, playedMoveCount = 0;
     int threadID = pos.thread();
     SplitPoint* sp = NULL;
@@ -807,7 +804,6 @@ namespace {
         tte = NULL;
         ttMove = excludedMove = MOVE_NONE;
         threatMove = sp->threatMove;
         tte = NULL;
         ttMove = excludedMove = MOVE_NONE;
         threatMove = sp->threatMove;
-        mateThreat = sp->mateThreat;
         goto split_point_start;
     }
     else if (Root)
         goto split_point_start;
     }
     else if (Root)
@@ -957,9 +953,6 @@ namespace {
             // move which was reduced. If a connection is found, return a fail
             // low score (which will cause the reduced move to fail high in the
             // parent node, which will trigger a re-search with full depth).
             // move which was reduced. If a connection is found, return a fail
             // low score (which will cause the reduced move to fail high in the
             // parent node, which will trigger a re-search with full depth).
-            if (nullValue == value_mated_in(ply + 2))
-                mateThreat = true;
-
             threatMove = (ss+1)->bestMove;
 
             if (   depth < ThreatDepth
             threatMove = (ss+1)->bestMove;
 
             if (   depth < ThreatDepth
@@ -985,10 +978,6 @@ namespace {
         tte = TT.retrieve(posKey);
     }
 
         tte = TT.retrieve(posKey);
     }
 
-    // Mate threat detection for PV nodes, otherwise we use null move search
-    if (PvNode)
-        mateThreat = pos.has_mate_threat();
-
 split_point_start: // At split points actual search starts from here
 
     // Initialize a MovePicker object for the current position
 split_point_start: // At split points actual search starts from here
 
     // Initialize a MovePicker object for the current position
@@ -1055,7 +1044,7 @@ split_point_start: // At split points actual search starts from here
       captureOrPromotion = pos.move_is_capture_or_promotion(move);
 
       // Step 11. Decide the new search depth
       captureOrPromotion = pos.move_is_capture_or_promotion(move);
 
       // Step 11. Decide the new search depth
-      ext = extension<PvNode>(pos, move, captureOrPromotion, moveIsCheck, mateThreat, &dangerous);
+      ext = extension<PvNode>(pos, move, captureOrPromotion, moveIsCheck, &dangerous);
 
       // Singular extension search. If all moves but one fail low on a search of
       // (alpha-s, beta-s), and just one fails high on (alpha, beta), then that move
 
       // Singular extension search. If all moves but one fail low on a search of
       // (alpha-s, beta-s), and just one fails high on (alpha, beta), then that move
@@ -1309,7 +1298,7 @@ split_point_start: // At split points actual search starts from here
           && !StopRequest
           && !ThreadsMgr.cutoff_at_splitpoint(threadID))
           ThreadsMgr.split<FakeSplit>(pos, ss, ply, &alpha, beta, &bestValue, depth,
           && !StopRequest
           && !ThreadsMgr.cutoff_at_splitpoint(threadID))
           ThreadsMgr.split<FakeSplit>(pos, ss, ply, &alpha, beta, &bestValue, depth,
-                                      threatMove, mateThreat, moveCount, &mp, PvNode);
+                                      threatMove, moveCount, &mp, PvNode);
     }
 
     // Step 19. Check for mate and stalemate
     }
 
     // Step 19. Check for mate and stalemate
@@ -1696,21 +1685,15 @@ split_point_start: // At split points actual search starts from here
   // the move is marked as 'dangerous' so, at least, we avoid to prune it.
   template <NodeType PvNode>
   Depth extension(const Position& pos, Move m, bool captureOrPromotion,
   // the move is marked as 'dangerous' so, at least, we avoid to prune it.
   template <NodeType PvNode>
   Depth extension(const Position& pos, Move m, bool captureOrPromotion,
-                  bool moveIsCheck, bool mateThreat, bool* dangerous) {
+                  bool moveIsCheck, bool* dangerous) {
 
     assert(m != MOVE_NONE);
 
     Depth result = DEPTH_ZERO;
 
     assert(m != MOVE_NONE);
 
     Depth result = DEPTH_ZERO;
-    *dangerous = moveIsCheck | mateThreat;
+    *dangerous = moveIsCheck;
 
 
-    if (*dangerous)
-    {
-        if (moveIsCheck && pos.see_sign(m) >= 0)
-            result += CheckExtension[PvNode];
-
-        if (mateThreat)
-            result += MateThreatExtension[PvNode];
-    }
+    if (moveIsCheck && pos.see_sign(m) >= 0)
+        result += CheckExtension[PvNode];
 
     if (pos.type_of_piece_on(move_from(m)) == PAWN)
     {
 
     if (pos.type_of_piece_on(move_from(m)) == PAWN)
     {
@@ -2311,7 +2294,7 @@ split_point_start: // At split points actual search starts from here
   template <bool Fake>
   void ThreadsManager::split(Position& pos, SearchStack* ss, int ply, Value* alpha,
                              const Value beta, Value* bestValue, Depth depth, Move threatMove,
   template <bool Fake>
   void ThreadsManager::split(Position& pos, SearchStack* ss, int ply, Value* alpha,
                              const Value beta, Value* bestValue, Depth depth, Move threatMove,
-                             bool mateThreat, int moveCount, MovePicker* mp, bool pvNode) {
+                             int moveCount, MovePicker* mp, bool pvNode) {
     assert(pos.is_ok());
     assert(ply > 0 && ply < PLY_MAX);
     assert(*bestValue >= -VALUE_INFINITE);
     assert(pos.is_ok());
     assert(ply > 0 && ply < PLY_MAX);
     assert(*bestValue >= -VALUE_INFINITE);
@@ -2346,7 +2329,6 @@ split_point_start: // At split points actual search starts from here
     splitPoint.ply = ply;
     splitPoint.depth = depth;
     splitPoint.threatMove = threatMove;
     splitPoint.ply = ply;
     splitPoint.depth = depth;
     splitPoint.threatMove = threatMove;
-    splitPoint.mateThreat = mateThreat;
     splitPoint.alpha = *alpha;
     splitPoint.beta = beta;
     splitPoint.pvNode = pvNode;
     splitPoint.alpha = *alpha;
     splitPoint.beta = beta;
     splitPoint.pvNode = pvNode;
index 463739fe2eff7c39617ad66ee59953214731676a..64804d45e19f9b882010ff1a0751a53cc3fade31 100644 (file)
@@ -36,7 +36,7 @@ struct SplitPoint {
   SplitPoint* parent;
   const Position* pos;
   Depth depth;
   SplitPoint* parent;
   const Position* pos;
   Depth depth;
-  bool pvNode, mateThreat;
+  bool pvNode;
   Value beta;
   int ply;
   int master;
   Value beta;
   int ply;
   int master;
index bf9b5c0f59d5a7b53f4fd554e68f5cb889346639..97cbe1a64684da2cddbcc86561bd19a7c1ff6063 100644 (file)
@@ -81,8 +81,6 @@ void init_uci_options() {
   Options["Cowardice"] = Option(100, 0, 200);
   Options["Check Extension (PV nodes)"] = Option(2, 0, 2);
   Options["Check Extension (non-PV nodes)"] = Option(1, 0, 2);
   Options["Cowardice"] = Option(100, 0, 200);
   Options["Check Extension (PV nodes)"] = Option(2, 0, 2);
   Options["Check Extension (non-PV nodes)"] = Option(1, 0, 2);
-  Options["Mate Threat Extension (PV nodes)"] = Option(2, 0, 2);
-  Options["Mate Threat Extension (non-PV nodes)"] = Option(2, 0, 2);
   Options["Pawn Push to 7th Extension (PV nodes)"] = Option(1, 0, 2);
   Options["Pawn Push to 7th Extension (non-PV nodes)"] = Option(1, 0, 2);
   Options["Passed Pawn Extension (PV nodes)"] = Option(1, 0, 2);
   Options["Pawn Push to 7th Extension (PV nodes)"] = Option(1, 0, 2);
   Options["Pawn Push to 7th Extension (non-PV nodes)"] = Option(1, 0, 2);
   Options["Passed Pawn Extension (PV nodes)"] = Option(1, 0, 2);