bitboard: remove unused multi shift
This commit is contained in:
parent
680a2d084c
commit
77bf0e6438
@ -46,38 +46,38 @@ impl BitBoard {
|
||||
self.0 == 0b0
|
||||
}
|
||||
|
||||
pub const fn east(&self, n: usize) -> Self {
|
||||
pub const fn east(&self) -> Self {
|
||||
let mask = !Self::col_mask(Board::SIZE - 1).0; // Mask to block column BOARD_SIZE-1 bits
|
||||
Self((self.0 & mask) << n)
|
||||
Self((self.0 & mask) << 1)
|
||||
}
|
||||
|
||||
pub const fn west(&self, n: usize) -> Self {
|
||||
pub const fn west(&self) -> Self {
|
||||
let mask = !Self::col_mask(0).0;
|
||||
Self((self.0 & mask) >> n)
|
||||
Self((self.0 & mask) >> 1)
|
||||
}
|
||||
|
||||
pub const fn north(&self, n: usize) -> Self {
|
||||
Self(self.0 >> (Board::SIZE as usize * n))
|
||||
pub const fn north(&self) -> Self {
|
||||
Self(self.0 >> Board::SIZE)
|
||||
}
|
||||
|
||||
pub const fn south(&self, n: usize) -> Self {
|
||||
Self(self.0 << (Board::SIZE as usize * n))
|
||||
pub const fn south(&self) -> Self {
|
||||
Self(self.0 << Board::SIZE)
|
||||
}
|
||||
|
||||
pub const fn northeast(&self, n: usize) -> Self {
|
||||
self.north(n).east(n)
|
||||
pub const fn northeast(&self) -> Self {
|
||||
self.north().east()
|
||||
}
|
||||
|
||||
pub const fn northwest(&self, n: usize) -> Self {
|
||||
self.north(n).west(n)
|
||||
pub const fn northwest(&self) -> Self {
|
||||
self.north().west()
|
||||
}
|
||||
|
||||
pub const fn southeast(&self, n: usize) -> Self {
|
||||
self.south(n).east(n)
|
||||
pub const fn southeast(&self) -> Self {
|
||||
self.south().east()
|
||||
}
|
||||
|
||||
pub const fn southwest(&self, n: usize) -> Self {
|
||||
self.south(n).west(n)
|
||||
pub const fn southwest(&self) -> Self {
|
||||
self.south().west()
|
||||
}
|
||||
|
||||
// Mask for a specific column (e.g., col_mask(7) = 0x8080808080808080)
|
||||
@ -133,15 +133,4 @@ mod test {
|
||||
b.set((2, 4).into(), false);
|
||||
assert!(!b.get((2, 4).into()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dir_multi() {
|
||||
let mut base = BitBoard::from_coord(CoordPair::from_axes(4, 4));
|
||||
base = base.southeast(1);
|
||||
base = base.southeast(1);
|
||||
assert_eq!(
|
||||
base,
|
||||
BitBoard::from_coord(CoordPair::from_axes(4, 4)).southeast(2)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -294,7 +294,7 @@ impl Board {
|
||||
// PERF! tested unrolling this loop using `const_for`
|
||||
// resulted in a 9% slowdown
|
||||
loop {
|
||||
current = $dir(¤t, 1);
|
||||
current = $dir(¤t);
|
||||
if current.is_empty() || !current.intersects(*opponent_board) {
|
||||
break;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user