X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.h;h=b2538e96b5cf9316dc2907bbfe43aec9d929dcc3;hp=d44ed009e5d2405d8cb0826241b936724e6df488;hb=7c5d724724e826ff1fd9a97c8812d5a4bffaaa84;hpb=7eaea3848c9e8a388c0b79cee6fba6bf3cd32108 diff --git a/src/position.h b/src/position.h index d44ed009..b2538e96 100644 --- a/src/position.h +++ b/src/position.h @@ -23,6 +23,7 @@ #include #include // For offsetof() +#include #include // For std::unique_ptr #include #include @@ -77,7 +78,8 @@ struct StateInfo { StateInfo* previous; }; -typedef std::unique_ptr> StateListPtr; +// In a std::deque references to elements are unaffected upon resizing +typedef std::unique_ptr> StateListPtr; /// Position class stores information regarding the board representation as @@ -129,6 +131,7 @@ public: Bitboard attacks_from(Piece pc, Square s) const; template Bitboard attacks_from(Square s) const; template Bitboard attacks_from(Square s, Color c) const; + Bitboard slider_blockers(Bitboard target, Bitboard sliders, Square s) const; // Properties of moves bool legal(Move m, Bitboard pinned) const; @@ -184,7 +187,6 @@ private: void set_state(StateInfo* si) const; // Other helpers - Bitboard check_blockers(Color c, Color kingColor) const; void put_piece(Color c, PieceType pt, Square s); void remove_piece(Color c, PieceType pt, Square s); void move_piece(Color c, PieceType pt, Square from, Square to); @@ -309,11 +311,11 @@ inline Bitboard Position::checkers() const { } inline Bitboard Position::discovered_check_candidates() const { - return check_blockers(sideToMove, ~sideToMove); + return slider_blockers(pieces(sideToMove), pieces(sideToMove), square(~sideToMove)); } inline Bitboard Position::pinned_pieces(Color c) const { - return check_blockers(c, c); + return slider_blockers(pieces(c), pieces(~c), square(c)); } inline bool Position::pawn_passed(Color c, Square s) const {