]> git.sesse.net Git - stockfish/commitdiff
Retire MovePicker::discovered_check_candidates()
authorMarco Costalba <mcostalba@gmail.com>
Wed, 4 Nov 2009 13:46:16 +0000 (14:46 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Thu, 5 Nov 2009 06:03:48 +0000 (07:03 +0100)
It is now no more needed to know dc candidates
inside MovePicker, so avoid calculating there.

No functional change.

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

index 18fb09439791e396b930f53bd0f0c2874ca6bd66..4784e95d93aa25b142d9244aa419bfdb196519e3 100644 (file)
@@ -143,13 +143,14 @@ MoveStack* generate_noncaptures(const Position& pos, MoveStack* mlist) {
 /// generate_non_capture_checks() generates all pseudo-legal non-captures and knight
 /// underpromotions that give check. Returns a pointer to the end of the move list.
 
-MoveStack* generate_non_capture_checks(const Position& pos, MoveStack* mlist, Bitboard dc) {
+MoveStack* generate_non_capture_checks(const Position& pos, MoveStack* mlist) {
 
   assert(pos.is_ok());
   assert(!pos.is_check());
 
   Color us = pos.side_to_move();
   Square ksq = pos.king_square(opposite_color(us));
+  Bitboard dc = pos.discovered_check_candidates(us);
 
   assert(pos.piece_on(ksq) == piece_of_color_and_type(opposite_color(us), KING));
 
index 7d2efec37883bafd5ec457a8232cfa80ce05e086..88d64053c4c6dadf6e10c6fedc8e7f8ea3dec2a1 100644 (file)
@@ -34,7 +34,7 @@
 
 extern MoveStack* generate_captures(const Position& pos, MoveStack* mlist);
 extern MoveStack* generate_noncaptures(const Position& pos, MoveStack* mlist);
-extern MoveStack* generate_non_capture_checks(const Position& pos, MoveStack* mlist, Bitboard dc);
+extern MoveStack* generate_non_capture_checks(const Position& pos, MoveStack* mlist);
 extern MoveStack* generate_evasions(const Position& pos, MoveStack* mlist);
 extern MoveStack* generate_moves(const Position& pos, MoveStack* mlist, bool pseudoLegal = false);
 extern bool move_is_legal(const Position& pos, const Move m, Bitboard pinned);
index a562662e359e514d878b17879dcd18395d940553..26627474536f37bd6e8f859ceb7a2cd909ef7dcd 100644 (file)
@@ -86,10 +86,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d,
   } else
       ttMoves[1].move = killers[0].move = killers[1].move = MOVE_NONE;
 
-  Color us = pos.side_to_move();
-
-  dc = p.discovered_check_candidates(us);
-  pinned = p.pinned_pieces(us);
+  pinned = p.pinned_pieces(pos.side_to_move());
 
   if (p.is_check())
       phasePtr = EvasionsPhaseTable;
@@ -155,7 +152,7 @@ void MovePicker::go_next_phase() {
 
   case PH_QCHECKS:
       // Perhaps we should order moves move here?  FIXME
-      lastMove = generate_non_capture_checks(pos, moves, dc);
+      lastMove = generate_non_capture_checks(pos, moves);
       return;
 
   case PH_STOP:
index 6c73629916a01afdbb24a29f25f1f352f80ca9e3..09ad1c39bfe995ae791e3c1af58ad6b45e17b848 100644 (file)
@@ -54,7 +54,6 @@ public:
   Move get_next_move();
   Move get_next_move(Lock& lock);
   int number_of_evasions() const;
-  Bitboard discovered_check_candidates() const;
 
 private:
   void score_captures();
@@ -69,7 +68,7 @@ private:
   int phase;
   const uint8_t* phasePtr;
   MoveStack *curMove, *lastMove, *lastBadCapture;
-  Bitboard dc, pinned;
+  Bitboard pinned;
   MoveStack moves[256], badCaptures[64];
 };
 
@@ -88,12 +87,4 @@ inline int MovePicker::number_of_evasions() const {
   return int(lastMove - moves);
 }
 
-/// 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 306cebfc75f0947f55f8bcc5bef18392a90b87da..c6c20dbce73d40c2e4f45270de6689c1e1eee8bd 100644 (file)
@@ -1718,11 +1718,10 @@ bool Position::has_mate_threat(Color c) {
 
   MoveStack mlist[120];
   bool result = false;
-  Bitboard dc = discovered_check_candidates(sideToMove);
   Bitboard pinned = pinned_pieces(sideToMove);
 
   // Generate pseudo-legal non-capture and capture check moves
-  MoveStack* last = generate_non_capture_checks(*this, mlist, dc);
+  MoveStack* last = generate_non_capture_checks(*this, mlist);
   last = generate_captures(*this, last);
 
   // Loop through the moves, and see if one of them is mate
index c323de5d48f35a62d00e56552449c1255f946f4e..978041e8ff5bad79f9483ac5fabc551165f802be 100644 (file)
@@ -334,7 +334,7 @@ int perft(Position& pos, Depth depth)
 {
     Move move;
     MovePicker mp = MovePicker(pos, MOVE_NONE, depth, H);
-    Bitboard dcCandidates = mp.discovered_check_candidates();
+    Bitboard dcCandidates = pos.discovered_check_candidates(pos.side_to_move());
     int sum = 0;
 
     // If we are at the last ply we don't need to do and undo
@@ -1110,7 +1110,7 @@ namespace {
     bool mateThreat = pos.has_mate_threat(opposite_color(us));
 
     MovePicker mp = MovePicker(pos, ttMove, depth, H, &ss[ply]);
-    Bitboard dcCandidates = mp.discovered_check_candidates();
+    Bitboard dcCandidates = pos.discovered_check_candidates(us);
 
     // Loop through all legal moves until no moves remain or a beta cutoff
     // occurs.
@@ -1363,7 +1363,8 @@ 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);
     Value futilityValue = VALUE_NONE;
     bool useFutilityPruning =   depth < SelectiveDepth
                              && !isCheck;
@@ -1583,8 +1584,8 @@ namespace {
     MovePicker mp = MovePicker(pos, ttMove, depth, H);
     Move move;
     int moveCount = 0;
-    Bitboard dcCandidates = mp.discovered_check_candidates();
     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