From 1da08df430d535c56c805204c2705eb33ebf2b6f Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Fri, 23 May 2025 18:39:18 -0700 Subject: [PATCH] [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. --- board/src/board.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/board/src/board.rs b/board/src/board.rs index 84b2700..966d611 100644 --- a/board/src/board.rs +++ b/board/src/board.rs @@ -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 {