[board] Implement rook::ClassicalMoveGenerator

Implement a rook move generator using the "classical" approach.
This approach walks each ray to find blockers and then masks out friendly pieces.
This is not efficient compared to other approaches, but it's much easier to implement.
This commit is contained in:
Eryn Wells 2024-01-06 19:51:06 -08:00
parent 6e483b412b
commit 359bab9173
4 changed files with 194 additions and 3 deletions

View file

@ -97,15 +97,16 @@ impl Position {
}
/// Return a BitBoard representing the set of squares containing a piece.
#[inline]
pub(crate) fn occupied_squares(&self) -> BitBoard {
self.pieces_per_color[Color::White as usize] | self.pieces_per_color[Color::Black as usize]
}
/// Return a BitBoard representing the set of squares containing a piece.
/// This set is the inverse of `occupied_squares`.
#[inline]
pub(crate) fn empty_squares(&self) -> BitBoard {
!(self.pieces_per_color[Color::White as usize]
| self.pieces_per_color[Color::Black as usize])
!self.occupied_squares()
}
pub(crate) fn bitboard_for_piece(&self, piece: Piece) -> BitBoard {