]> git.sesse.net Git - stockfish/blobdiff - src/position.h
Change pawn_attacks() API
[stockfish] / src / position.h
index 8e6fa93876ff1573364f6008b485c45794963293..1505874e9f0269111f338fd5d09f0a2efca95b7b 100644 (file)
@@ -183,36 +183,28 @@ public:
   Square initial_kr_square(Color c) const;
   Square initial_qr_square(Color c) const;
 
-  // Attack bitboards
-  Bitboard sliding_attacks(Square s, Direction d) const;
-  Bitboard ray_attacks(Square s, SignedDirection d) const;
-  Bitboard pawn_attacks(Color c, Square s) const;
-
-  template<PieceType>
-  Bitboard piece_attacks(Square s) const;
-
   // Bitboards for pinned pieces and discovered check candidates
   Bitboard discovered_check_candidates(Color c) const;
   Bitboard pinned_pieces(Color c, Bitboard& p) const;
   Bitboard pinned_pieces(Color c) const;
 
-  // Checking pieces
+  // Checking pieces and under check information
   Bitboard checkers() const;
+  bool is_check() const;
 
   // Piece lists
   Square piece_list(Color c, PieceType pt, int index) const;
 
-  // Attack information for a given square
-  bool square_is_attacked(Square s, Color c) const;
+  // Attack information to a given square
   Bitboard attacks_to(Square s) const;
   Bitboard attacks_to(Square s, Color c) const;
-  bool is_check() const;
-  bool pawn_attacks_square(Color c, Square f, Square t) const;
-
-  template<PieceType>
-  Bitboard piece_attacks_square(Square f, Square t) const; // Dispatch at compile-time
+  template<PieceType> Bitboard piece_attacks(Square s) const;
+  Bitboard pawn_attacks(Square s, Color c) const;
 
+  // Attack information to a given square from another given square
+  template<PieceType> Bitboard piece_attacks_square(Square f, Square t) const; // Dispatch at compile-time
   bool piece_attacks_square(Piece p, Square f, Square t) const; // Dispatch at run-time
+  bool pawn_attacks_square(Square f, Square t, Color c) const;
 
   // Properties of moves
   bool pl_move_is_legal(Move m) const;
@@ -278,7 +270,7 @@ public:
   // Position consistency check, for debugging
   bool is_ok(int* failedStep = NULL) const;
 
-  // Static member functions:
+  // Static member functions
   static void init_zobrist();
   static void init_piece_square_tables();
 
@@ -445,7 +437,7 @@ inline Square Position::initial_qr_square(Color c) const {
   return relative_square(c, make_square(initialQRFile, RANK_1));
 }
 
-inline Bitboard Position::pawn_attacks(Color c, Square s) const {
+inline Bitboard Position::pawn_attacks(Square s, Color c) const {
   return StepAttackBB[piece_of_color_and_type(c, PAWN)][s];
 }
 
@@ -482,8 +474,8 @@ inline bool Position::is_check() const {
   return st->checkersBB != EmptyBoardBB;
 }
 
-inline bool Position::pawn_attacks_square(Color c, Square f, Square t) const {
-  return bit_is_set(pawn_attacks(c, f), t);
+inline bool Position::pawn_attacks_square(Square f, Square t, Color c) const {
+  return bit_is_set(pawn_attacks(f, c), t);
 }
 
 template<PieceType Piece>
@@ -496,11 +488,6 @@ inline Bitboard Position::attacks_to(Square s, Color c) const {
   return attacks_to(s) & pieces_of_color(c);
 }
 
-inline bool Position::square_is_attacked(Square s, Color c) const {
-
-  return attacks_to(s, c) != EmptyBoardBB;
-}
-
 inline bool Position::pawn_is_passed(Color c, Square s) const {
   return !(pieces(PAWN, opposite_color(c)) & passed_pawn_mask(c, s));
 }