diff --git a/board/src/bitboard/shifts.rs b/board/src/bitboard/shifts.rs index 3b1da02..2370306 100644 --- a/board/src/bitboard/shifts.rs +++ b/board/src/bitboard/shifts.rs @@ -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)