[board] Implement BitBoard::shift_east
This commit is contained in:
parent
1a986e4c27
commit
90db9b194f
1 changed files with 11 additions and 1 deletions
|
@ -21,6 +21,12 @@ impl BitBoard {
|
||||||
BitBoard(self.0 << 9 & BitBoard::NOT_A_FILE)
|
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]
|
#[inline]
|
||||||
pub fn shift_east_one(&self) -> BitBoard {
|
pub fn shift_east_one(&self) -> BitBoard {
|
||||||
BitBoard(self.0 << 1 & BitBoard::NOT_A_FILE)
|
BitBoard(self.0 << 1 & BitBoard::NOT_A_FILE)
|
||||||
|
@ -60,7 +66,6 @@ impl BitBoard {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::Square;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cardinal_direction_shifts() {
|
fn cardinal_direction_shifts() {
|
||||||
|
@ -105,6 +110,11 @@ mod tests {
|
||||||
BitBoard(0x0008_0000_0000_0000)
|
BitBoard(0x0008_0000_0000_0000)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
BitBoard(0x0008_0000_0000).shift_east(2),
|
||||||
|
BitBoard(0x0020_0000_0000)
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
BitBoard(0x0008_0000_0000).shift_south(2),
|
BitBoard(0x0008_0000_0000).shift_south(2),
|
||||||
BitBoard(0x0008_0000)
|
BitBoard(0x0008_0000)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue