From 90db9b194f60f628fe0526bf6b99d3a8e4cf8274 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Fri, 29 Dec 2023 08:39:51 -0800 Subject: [PATCH] [board] Implement BitBoard::shift_east --- board/src/bitboard/shifts.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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)