X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fposition.h;h=1078e03ed75fa5a4aa42bed002f0d7f820517c09;hb=9a11a291942a8a7b1ebb36282c666ca8d1be1892;hp=d94ef185ac9c45a47de27148ce34f8dfe0ff3685;hpb=e917bd59b1e317c6b48dc676473359fdfb86d9d4;p=stockfish diff --git a/src/position.h b/src/position.h index d94ef185..1078e03e 100644 --- a/src/position.h +++ b/src/position.h @@ -95,6 +95,7 @@ public: template int count() const; template const Square* squares(Color c) const; template Square square(Color c) const; + int semiopen_file(Color c, File f) const; // Castling int castling_rights(Color c) const; @@ -128,6 +129,7 @@ public: // Piece specific bool pawn_passed(Color c, Square s) const; bool opposite_bishops() const; + int pawns_on_same_color_squares(Color c, Square s) const; // Doing and undoing moves void do_move(Move m, StateInfo& newSt); @@ -260,12 +262,16 @@ inline Square Position::ep_square() const { return st->epSquare; } +inline int Position::semiopen_file(Color c, File f) const { + return !(pieces(c, PAWN) & file_bb(f)); +} + inline bool Position::can_castle(CastlingRight cr) const { return st->castlingRights & cr; } inline int Position::castling_rights(Color c) const { - return st->castlingRights & ((WHITE_OO | WHITE_OOO) << (2 * c)); + return st->castlingRights & (c == WHITE ? WHITE_CASTLING : BLACK_CASTLING); } inline bool Position::castling_impeded(CastlingRight cr) const { @@ -310,7 +316,7 @@ inline Bitboard Position::check_squares(PieceType pt) const { } inline bool Position::pawn_passed(Color c, Square s) const { - return !(pieces(~c, PAWN) & passed_pawn_mask(c, s)); + return !(pieces(~c, PAWN) & passed_pawn_span(c, s)); } inline bool Position::advanced_pawn_push(Move m) const { @@ -318,6 +324,10 @@ inline bool Position::advanced_pawn_push(Move m) const { && relative_rank(sideToMove, from_sq(m)) > RANK_4; } +inline int Position::pawns_on_same_color_squares(Color c, Square s) const { + return popcount(pieces(c, PAWN) & ((DarkSquares & s) ? DarkSquares : ~DarkSquares)); +} + inline Key Position::key() const { return st->key; } @@ -413,7 +423,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 = SquareBB[from] ^ SquareBB[to]; + Bitboard fromTo = square_bb(from) | square_bb(to); byTypeBB[ALL_PIECES] ^= fromTo; byTypeBB[type_of(pc)] ^= fromTo; byColorBB[color_of(pc)] ^= fromTo;