X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fposition.h;h=cc606a5ab00af8dcb0d7a6dbed9ec326997b7222;hb=7077fbdd1481829a0a20b6975c4245609118b938;hp=3de24f228882d398b06e6ec8331d1b9542acac17;hpb=b60f9cc4515cdfb657a0166abb29a60257cc59e1;p=stockfish diff --git a/src/position.h b/src/position.h index 3de24f22..cc606a5a 100644 --- a/src/position.h +++ b/src/position.h @@ -68,7 +68,7 @@ struct StateInfo { /// start position to the position just before the search starts). Needed by /// 'draw by repetition' detection. Use a std::deque because pointers to /// elements are not invalidated upon list resizing. -typedef std::unique_ptr> StateListPtr; +using StateListPtr = std::unique_ptr>; /// Position class stores information regarding the board representation as @@ -126,6 +126,7 @@ public: bool legal(Move m) const; bool pseudo_legal(const Move m) const; bool capture(Move m) const; + bool capture_stage(Move m) const; bool gives_check(Move m) const; Piece moved_piece(Move m) const; Piece captured_piece() const; @@ -383,8 +384,16 @@ inline bool Position::is_chess960() const { inline bool Position::capture(Move m) const { assert(is_ok(m)); - // Castling is encoded as "king captures rook" - return (!empty(to_sq(m)) && type_of(m) != CASTLING) || type_of(m) == EN_PASSANT; + return (!empty(to_sq(m)) && type_of(m) != CASTLING) + || type_of(m) == EN_PASSANT; +} + +// returns true if a move is generated from the capture stage +// having also queen promotions covered, i.e. consistency with the capture stage move generation +// is needed to avoid the generation of duplicate moves. +inline bool Position::capture_stage(Move m) const { + assert(is_ok(m)); + return capture(m) || promotion_type(m) == QUEEN; } inline Piece Position::captured_piece() const {