From d9e4f16ec8be800d2fadcfc9fe3a234f1c311db3 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 1 Apr 2024 01:29:39 +0100 Subject: [PATCH] Add 'ChessBoard::occupancy' --- src/board/chess_board.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/board/chess_board.rs b/src/board/chess_board.rs index 9b5427a..2f58b31 100644 --- a/src/board/chess_board.rs +++ b/src/board/chess_board.rs @@ -61,6 +61,12 @@ impl ChessBoard { &mut self.castle_rights[color.index()] } + /// Get the [Bitboard] representing all pieces of the given [Piece] and [Color] type. + #[inline(always)] + pub fn occupancy(&self, piece: Piece, color: Color) -> Bitboard { + self.piece_occupancy(piece) & self.color_occupancy(color) + } + /// Get the [Bitboard] representing all pieces of the given [Piece] type, discarding color. #[inline(always)] pub fn piece_occupancy(&self, piece: Piece) -> Bitboard {