board optimizations

This commit is contained in:
2025-03-12 10:28:32 -04:00
parent 7863e0324f
commit 16eb6a1259
2 changed files with 47 additions and 51 deletions

View File

@@ -79,18 +79,6 @@ impl BitBoard {
self.south(n).west(n)
}
/// All direction methods
pub const DIRECTIONS: [fn(&Self, usize) -> Self; 8] = [
BitBoard::east,
BitBoard::west,
BitBoard::north,
BitBoard::south,
BitBoard::northeast,
BitBoard::northwest,
BitBoard::southeast,
BitBoard::southwest,
];
// Mask for a specific column (e.g., col_mask(7) = 0x8080808080808080)
const fn col_mask(col: CoordAxis) -> Self {
let mut mask = 0;
@@ -110,12 +98,16 @@ impl BitBoard {
pub const fn intersects(self, other: Self) -> bool {
(self.0 & other.0) > 0
}
}
impl std::ops::Not for BitBoard {
type Output = BitBoard;
pub const fn bitor_assign(&mut self, other: Self) {
self.0 = self.0 | other.0;
}
fn not(self) -> Self::Output {
pub const fn bitand_assign(&mut self, other: Self) {
self.0 = self.0 & other.0;
}
pub const fn not(self) -> Self {
Self(!self.0)
}
}
@@ -136,18 +128,6 @@ impl std::ops::BitOr for BitBoard {
}
}
impl std::ops::BitAndAssign for BitBoard {
fn bitand_assign(&mut self, rhs: Self) {
*self = *self & rhs;
}
}
impl std::ops::BitOrAssign for BitBoard {
fn bitor_assign(&mut self, rhs: Self) {
*self = *self | rhs;
}
}
#[cfg(test)]
mod test {
use super::*;