[board] Implement a couple handy piece getters

Board::find_pieces returns a BitBoard for all the pieces matching the given Piece.

Board::enemies returns a BitBoard of all the enemy pieces of a given Color.

Board::pawns returns a BitBoard of all the pawns of a given Color.
This commit is contained in:
Eryn Wells 2025-05-23 18:39:18 -07:00
parent c02f0170b9
commit 1da08df430

View file

@ -63,6 +63,10 @@ impl Board {
self.pieces.get(square)
}
pub fn find_pieces(&self, piece: Piece) -> BitBoard {
self.pieces.find_pieces(piece)
}
/// Place a piece on the board.
///
/// ## Errors
@ -102,6 +106,15 @@ impl Board {
pub fn opposing_occupancy(&self, color: Color) -> BitBoard {
self.pieces.opposing_occupancy(color)
}
pub fn enemies(&self, color: Color) -> BitBoard {
self.pieces.opposing_occupancy(color)
}
/// Return a [`BitBoard`] of all pawns of a given color.
pub fn pawns(&self, color: Color) -> BitBoard {
self.pieces.find_pieces(Piece::pawn(color))
}
}
impl Board {