X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.h;h=2ec2729cf3a256efcdeaa53a2fc0ca5a725a20ee;hp=2106414ba2dd4f3475bf5cb42e2149539e939abf;hb=cff9a8672c1da7d36bc54d168d10ea2b1ce5c728;hpb=4ae5a7b45a430aea5f4b21f9455b4db74ed1c44a diff --git a/src/position.h b/src/position.h index 2106414b..2ec2729c 100644 --- a/src/position.h +++ b/src/position.h @@ -100,9 +100,9 @@ public: // Castling int castling_rights(Color c) const; - bool can_castle(CastlingRight cr) const; - bool castling_impeded(CastlingRight cr) const; - Square castling_rook_square(CastlingRight cr) const; + bool can_castle(CastlingRights cr) const; + bool castling_impeded(CastlingRights cr) const; + Square castling_rook_square(CastlingRights cr) const; // Checking Bitboard checkers() const; @@ -268,7 +268,7 @@ inline bool Position::is_on_semiopen_file(Color c, Square s) const { return !(pieces(c, PAWN) & file_bb(s)); } -inline bool Position::can_castle(CastlingRight cr) const { +inline bool Position::can_castle(CastlingRights cr) const { return st->castlingRights & cr; } @@ -276,17 +276,18 @@ inline int Position::castling_rights(Color c) const { return st->castlingRights & (c == WHITE ? WHITE_CASTLING : BLACK_CASTLING); } -inline bool Position::castling_impeded(CastlingRight cr) const { +inline bool Position::castling_impeded(CastlingRights cr) const { return byTypeBB[ALL_PIECES] & castlingPath[cr]; } -inline Square Position::castling_rook_square(CastlingRight cr) const { +inline Square Position::castling_rook_square(CastlingRights cr) const { return castlingRookSquare[cr]; } template inline Bitboard Position::attacks_from(Square s) const { - assert(Pt != PAWN); + static_assert(Pt != PAWN, "Pawn attacks need color"); + return Pt == BISHOP || Pt == ROOK ? attacks_bb(s, byTypeBB[ALL_PIECES]) : Pt == QUEEN ? attacks_from(s) | attacks_from(s) : PseudoAttacks[Pt][s]; @@ -429,7 +430,7 @@ inline void Position::move_piece(Piece pc, Square from, Square to) { // index[from] is not updated and becomes stale. This works as long as index[] // is accessed just by known occupied squares. - Bitboard fromTo = square_bb(from) | square_bb(to); + Bitboard fromTo = from | to; byTypeBB[ALL_PIECES] ^= fromTo; byTypeBB[type_of(pc)] ^= fromTo; byColorBB[color_of(pc)] ^= fromTo;