rename board variables
This commit is contained in:
@@ -11,7 +11,7 @@ pub type BitBoardInner = u64;
|
||||
pub struct BitBoard(BitBoardInner);
|
||||
|
||||
// BitBoard should be big enough to fit all points on the board
|
||||
const_assert!(std::mem::size_of::<BitBoard>() * 8 >= Board::BOARD_AREA.0 as usize);
|
||||
const_assert!(std::mem::size_of::<BitBoard>() * 8 >= Board::AREA.0 as usize);
|
||||
|
||||
impl BitBoard {
|
||||
#[allow(clippy::new_without_default)]
|
||||
@@ -46,7 +46,7 @@ impl BitBoard {
|
||||
}
|
||||
|
||||
pub const fn east(&self, n: usize) -> Self {
|
||||
let mask = !Self::col_mask(Board::BOARD_SIZE - 1).0; // Mask to block column BOARD_SIZE-1 bits
|
||||
let mask = !Self::col_mask(Board::SIZE - 1).0; // Mask to block column BOARD_SIZE-1 bits
|
||||
Self((self.0 & mask) << n)
|
||||
}
|
||||
|
||||
@@ -56,11 +56,11 @@ impl BitBoard {
|
||||
}
|
||||
|
||||
pub const fn north(&self, n: usize) -> Self {
|
||||
Self(self.0 >> (Board::BOARD_SIZE as usize * n))
|
||||
Self(self.0 >> (Board::SIZE as usize * n))
|
||||
}
|
||||
|
||||
pub const fn south(&self, n: usize) -> Self {
|
||||
Self(self.0 << (Board::BOARD_SIZE as usize * n))
|
||||
Self(self.0 << (Board::SIZE as usize * n))
|
||||
}
|
||||
|
||||
pub const fn northeast(&self, n: usize) -> Self {
|
||||
@@ -95,9 +95,9 @@ impl BitBoard {
|
||||
const fn col_mask(col: CoordAxis) -> Self {
|
||||
let mut mask = 0;
|
||||
let mut i = 0;
|
||||
while i < Board::BOARD_AREA.0 {
|
||||
while i < Board::AREA.0 {
|
||||
mask |= 1 << (i + col);
|
||||
i += Board::BOARD_SIZE;
|
||||
i += Board::SIZE;
|
||||
}
|
||||
Self(mask)
|
||||
}
|
||||
@@ -155,7 +155,7 @@ mod test {
|
||||
#[test]
|
||||
fn set_and_get() {
|
||||
let mut b = BitBoard::new();
|
||||
for c in 0..Board::BOARD_AREA.0 {
|
||||
for c in 0..Board::AREA.0 {
|
||||
assert!(
|
||||
!b.get(CoordPair(c)),
|
||||
"A just-initalized BitBoard should be completely empty"
|
||||
|
||||
Reference in New Issue
Block a user