[board] Implement BitBoard::shift_east

This commit is contained in:
Eryn Wells 2023-12-29 08:39:51 -08:00
parent 1a986e4c27
commit 90db9b194f

View file

@ -21,6 +21,12 @@ impl BitBoard {
BitBoard(self.0 << 9 & BitBoard::NOT_A_FILE)
}
#[inline]
pub fn shift_east(&self, n: u8) -> BitBoard {
// TODO: Implement a bounds check here.
BitBoard(self.0 << n)
}
#[inline]
pub fn shift_east_one(&self) -> BitBoard {
BitBoard(self.0 << 1 & BitBoard::NOT_A_FILE)
@ -60,7 +66,6 @@ impl BitBoard {
#[cfg(test)]
mod tests {
use super::*;
use crate::Square;
#[test]
fn cardinal_direction_shifts() {
@ -105,6 +110,11 @@ mod tests {
BitBoard(0x0008_0000_0000_0000)
);
assert_eq!(
BitBoard(0x0008_0000_0000).shift_east(2),
BitBoard(0x0020_0000_0000)
);
assert_eq!(
BitBoard(0x0008_0000_0000).shift_south(2),
BitBoard(0x0008_0000)