Add 'ChessBoard::occupancy'

This commit is contained in:
Bruno BELANYI 2024-04-01 01:29:39 +01:00
parent c115e357e1
commit 23a4e857a0

View file

@ -61,6 +61,12 @@ impl ChessBoard {
&mut self.castle_rights[color.index()] &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. /// Get the [Bitboard] representing all pieces of the given [Piece] type, discarding color.
#[inline(always)] #[inline(always)]
pub fn piece_occupancy(&self, piece: Piece) -> Bitboard { pub fn piece_occupancy(&self, piece: Piece) -> Bitboard {