]> git.sesse.net Git - stockfish/blobdiff - src/position.h
Split calculation of pinners from dc candidates
[stockfish] / src / position.h
index 8d1ba3598c2da91c9252bbdf39efa3be3fea3fda..4f18e67feeb37381c97534ec8abc0d7719167ebd 100644 (file)
@@ -83,10 +83,10 @@ struct StateInfo {
   Key key, pawnKey, materialKey;
   int castleRights, rule50;
   Square epSquare;
-  Move lastMove;
   Value mgValue, egValue;
   PieceType capture;
   StateInfo* previous;
+  Move lastMove;
 };
 
 
@@ -240,6 +240,7 @@ public:
   bool square_is_weak(Square s, Color c) const;
 
   // Doing and undoing moves
+  void setStartState(const StateInfo& st);
   void do_move(Move m, StateInfo& st);
   void undo_move(Move m);
   void do_null_move(StateInfo& st);
@@ -287,6 +288,12 @@ public:
   static void init_piece_square_tables();
 
 private:
+
+  enum {
+      Pinned       = 1,
+      DcCandidates = 2
+  };
+
   // Initialization helper functions (used while setting up a position)
   void clear();
   void put_piece(Piece p, Square s);
@@ -302,6 +309,9 @@ private:
   void undo_promotion_move(Move m);
   void undo_ep_move(Move m);
   void find_checkers();
+  void find_hidden_checks(Color us, unsigned int types);
+  void find_hidden_checks();
+  void update_hidden_checks(Square from, Square to);
 
   template<PieceType Piece>
   void update_checkers(Bitboard* pCheckersBB, Square ksq, Square from, Square to, Bitboard dcCandidates);
@@ -556,6 +566,19 @@ inline Bitboard Position::piece_attacks<KING>(Square s) const {
   return StepAttackBB[KING][s];
 }
 
+inline Bitboard Position::pinned_pieces(Color c) const {
+  return st->pinned[c];
+}
+
+inline Bitboard Position::pinned_pieces(Color c, Bitboard& p) const {
+  p = st->pinners[c];
+  return st->pinned[c];
+}
+
+inline Bitboard Position::discovered_check_candidates(Color c) const {
+  return st->dcCandidates[c];
+}
+
 inline Bitboard Position::checkers() const {
   return st->checkersBB;
 }