]> git.sesse.net Git - stockfish/commitdiff
Do not pass discovery check candidates in Position::do_move()
authorMarco Costalba <mcostalba@gmail.com>
Thu, 19 Feb 2009 16:29:36 +0000 (17:29 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Thu, 19 Feb 2009 16:29:36 +0000 (17:29 +0100)
Also remove any bit of 'pinned' and co. from MovePicker class.

No functional change.

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

index 4c75b0fe2c00dfb0e464f113e9ad911cb53b57a6..59b134532e4ec5318884c9b2810d902d0af337cb 100644 (file)
@@ -96,9 +96,6 @@ MovePicker::MovePicker(const Position& p, bool pv, Move ttm,
   else
       phaseIndex = (noCaptures ? NoMovesPhaseIndex : QsearchWithoutChecksPhaseIndex);
 
-  dc = p.discovered_check_candidates(us);
-  pinned = p.pinned_pieces(p.side_to_move());
-
   finished = false;
 }
 
index 2c861c71db873377800dca30e2e3d82096739dd2..e0d6ca53ca1b091e875e5b5ac88da0cc153c1f92 100644 (file)
@@ -69,7 +69,6 @@ public:
   int number_of_moves() const;
   int current_move_score() const;
   MovegenPhase current_move_type() const;
-  Bitboard discovered_check_candidates() const;
 
   static void init_phase_table();
 
@@ -84,7 +83,6 @@ private:
 
   const Position& pos;
   Move ttMove, mateKiller, killer1, killer2;
-  Bitboard pinned, dc;
   MoveStack moves[256], badCaptures[64];
   bool pvNode;
   Depth depth;
@@ -109,12 +107,4 @@ inline int MovePicker::number_of_moves() const {
   return numOfMoves;
 }
 
-/// MovePicker::discovered_check_candidates() returns a bitboard containing
-/// all pieces which can possibly give discovered check.  This bitboard is
-/// computed by the constructor function.
-
-inline Bitboard MovePicker::discovered_check_candidates() const {
-  return dc;
-}
-
 #endif // !defined(MOVEPICK_H_INCLUDED)
index 6d4e66cab6c4ddd2eee1e002e1864a0a84ade466..fdf3e911e9db32250781f6f8287451cc6eccbedf 100644 (file)
@@ -748,22 +748,16 @@ inline void Position::update_checkers(Bitboard* pCheckersBB, Square ksq, Square
 /// Position::do_move() makes a move, and backs up all information necessary
 /// to undo the move to an UndoInfo object. The move is assumed to be legal.
 /// Pseudo-legal moves should be filtered out before this function is called.
-/// There are two versions of this function, one which takes only the move and
-/// the UndoInfo as input, and one which takes a third parameter, a bitboard of
-/// discovered check candidates. The second version is faster, because knowing
-/// the discovered check candidates makes it easier to update the checkersBB
-/// member variable in the position object.
 
 void Position::do_move(Move m, UndoInfo& u) {
 
-  do_move(m, u, discovered_check_candidates(side_to_move()));
-}
-
-void Position::do_move(Move m, UndoInfo& u, Bitboard dc) {
-
   assert(is_ok());
   assert(move_is_ok(m));
 
+  // Get now the current (pre-move) dc candidates that we will use
+  // in update_checkers().
+  Bitboard oldDcCandidates = discovered_check_candidates(side_to_move());
+
   // Back up the necessary information to our UndoInfo object (except the
   // captured piece, which is taken care of later.
   backup(u);
@@ -871,12 +865,12 @@ void Position::do_move(Move m, UndoInfo& u, Bitboard dc) {
     Square ksq = king_square(them);
     switch (piece)
     {
-    case PAWN:   update_checkers<PAWN>(&checkersBB, ksq, from, to, dc);   break;
-    case KNIGHT: update_checkers<KNIGHT>(&checkersBB, ksq, from, to, dc); break;
-    case BISHOP: update_checkers<BISHOP>(&checkersBB, ksq, from, to, dc); break;
-    case ROOK:   update_checkers<ROOK>(&checkersBB, ksq, from, to, dc);   break;
-    case QUEEN:  update_checkers<QUEEN>(&checkersBB, ksq, from, to, dc);  break;
-    case KING:   update_checkers<KING>(&checkersBB, ksq, from, to, dc);   break;
+    case PAWN:   update_checkers<PAWN>(&checkersBB, ksq, from, to, oldDcCandidates);   break;
+    case KNIGHT: update_checkers<KNIGHT>(&checkersBB, ksq, from, to, oldDcCandidates); break;
+    case BISHOP: update_checkers<BISHOP>(&checkersBB, ksq, from, to, oldDcCandidates); break;
+    case ROOK:   update_checkers<ROOK>(&checkersBB, ksq, from, to, oldDcCandidates);   break;
+    case QUEEN:  update_checkers<QUEEN>(&checkersBB, ksq, from, to, oldDcCandidates);  break;
+    case KING:   update_checkers<KING>(&checkersBB, ksq, from, to, oldDcCandidates);   break;
     default: assert(false); break;
     }
   }
index b526bfe7e6e39c039f0b95d93f365b651057492c..94b7003373d817fe6f40be5b13701b4197c6fd20 100644 (file)
@@ -244,7 +244,6 @@ public:
   void backup(UndoInfo &u) const;
   void restore(const UndoInfo &u);
   void do_move(Move m, UndoInfo &u);
-  void do_move(Move m, UndoInfo &u, Bitboard dcCandidates);
   void undo_move(Move m, const UndoInfo &u);
   void do_null_move(UndoInfo &u);
   void undo_null_move(const UndoInfo &u);
index d54087b966e35c5ef09a131f48e3932d8657d12e..e621d702dc42edd456cf80513ad879f3209efc55 100644 (file)
@@ -809,7 +809,7 @@ namespace {
         newDepth = (Iteration - 2) * OnePly + ext + InitialDepth;
 
         // Make the move, and search it
-        pos.do_move(move, u, dcCandidates);
+        pos.do_move(move, u);
 
         if (i < MultiPV)
         {
@@ -983,9 +983,10 @@ namespace {
     Move move, movesSearched[256];
     int moveCount = 0;
     Value value, bestValue = -VALUE_INFINITE;
-    Bitboard dcCandidates = mp.discovered_check_candidates();
+    Color us = pos.side_to_move();
+    Bitboard dcCandidates = pos.discovered_check_candidates(us);
     bool isCheck = pos.is_check();
-    bool mateThreat = pos.has_mate_threat(opposite_color(pos.side_to_move()));
+    bool mateThreat = pos.has_mate_threat(opposite_color(us));
 
     // Loop through all legal moves until no moves remain or a beta cutoff
     // occurs.
@@ -1014,7 +1015,7 @@ namespace {
 
       // Make and search the move
       UndoInfo u;
-      pos.do_move(move, u, dcCandidates);
+      pos.do_move(move, u);
 
       if (moveCount == 1) // The first move in list is the PV
           value = -search_pv(pos, ss, -beta, -alpha, newDepth, ply+1, threadID);
@@ -1283,7 +1284,7 @@ namespace {
     Move move, movesSearched[256];
     int moveCount = 0;
     Value value, bestValue = -VALUE_INFINITE;
-    Bitboard dcCandidates = mp.discovered_check_candidates();
+    Bitboard dcCandidates = pos.discovered_check_candidates(pos.side_to_move());
     Value futilityValue = VALUE_NONE;
     bool useFutilityPruning =   UseFutilityPruning
                              && depth < SelectiveDepth
@@ -1338,7 +1339,7 @@ namespace {
 
       // Make and search the move
       UndoInfo u;
-      pos.do_move(move, u, dcCandidates);
+      pos.do_move(move, u);
 
       // Try to reduce non-pv search depth by one ply if move seems not problematic,
       // if the move fails high will be re-searched at full depth.
@@ -1470,8 +1471,9 @@ namespace {
     MovePicker mp = MovePicker(pos, pvNode, MOVE_NONE, EmptySearchStack, depth, isCheck ? NULL : &ei);
     Move move;
     int moveCount = 0;
-    Bitboard dcCandidates = mp.discovered_check_candidates();
-    bool enoughMaterial = pos.non_pawn_material(pos.side_to_move()) > RookValueMidgame;
+    Color us = pos.side_to_move();
+    Bitboard dcCandidates = pos.discovered_check_candidates(us);
+    bool enoughMaterial = pos.non_pawn_material(us) > RookValueMidgame;
 
     // Loop through the moves until no moves remain or a beta cutoff
     // occurs.
@@ -1517,7 +1519,7 @@ namespace {
 
       // Make and search the move.
       UndoInfo u;
-      pos.do_move(move, u, dcCandidates);
+      pos.do_move(move, u);
       Value value = -qsearch(pos, ss, -beta, -alpha, depth-OnePly, ply+1, threadID);
       pos.undo_move(move, u);
 
@@ -1610,7 +1612,7 @@ namespace {
 
       // Make and search the move.
       UndoInfo u;
-      pos.do_move(move, u, sp->dcCandidates);
+      pos.do_move(move, u);
 
       // Try to reduce non-pv search depth by one ply if move seems not problematic,
       // if the move fails high will be re-searched at full depth.
@@ -1721,7 +1723,7 @@ namespace {
 
       // Make and search the move.
       UndoInfo u;
-      pos.do_move(move, u, sp->dcCandidates);
+      pos.do_move(move, u);
 
       // Try to reduce non-pv search depth by one ply if move seems not problematic,
       // if the move fails high will be re-searched at full depth.