cleanup
This commit is contained in:
@@ -26,19 +26,15 @@ 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);
|
||||
|
||||
impl Default for BitBoard {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl BitBoard {
|
||||
#[cfg(feature = "bitvec")]
|
||||
#[allow(clippy::new_without_default)]
|
||||
pub const fn new() -> Self {
|
||||
Self(bitarr!(BBBaseType, Lsb0; 0; Board::BOARD_AREA))
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "bitvec"))]
|
||||
#[allow(clippy::new_without_default)]
|
||||
pub const fn new() -> Self {
|
||||
Self(0)
|
||||
}
|
||||
|
||||
@@ -14,24 +14,17 @@ type Chain = ArrayVec<(usize, usize), { Board::BOARD_SIZE - 1 }>;
|
||||
/// A collection of chains (up vert, down vert, left horiz, right horiz, diagonals....)
|
||||
type ChainCollection = ArrayVec<Chain, 8>;
|
||||
|
||||
const BOARD_AREA: usize = Board::BOARD_AREA;
|
||||
|
||||
/// Map of all points on the board against some type T
|
||||
/// Used to index like so: example[i][j]
|
||||
/// with each coordinate
|
||||
pub struct PosMap<T: Default>(ArrayVec<T, BOARD_AREA>);
|
||||
|
||||
impl<T: Default> Default for PosMap<T> {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
pub struct PosMap<T: Default>(ArrayVec<T, { Board::BOARD_AREA }>);
|
||||
|
||||
impl<T: Default> PosMap<T> {
|
||||
const fn index(row: usize, col: usize) -> usize {
|
||||
row * Board::BOARD_SIZE + col
|
||||
}
|
||||
|
||||
#[allow(clippy::new_without_default)]
|
||||
pub fn new() -> Self {
|
||||
Self(ArrayVec::from_iter(
|
||||
(0..Board::BOARD_AREA).map(|_| Default::default()),
|
||||
@@ -186,12 +179,6 @@ impl fmt::Debug for Board {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Board {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Board {
|
||||
pub const BOARD_SIZE: usize = 8;
|
||||
|
||||
@@ -199,6 +186,7 @@ impl Board {
|
||||
pub const BOARD_AREA: usize = Self::BOARD_SIZE.pow(2);
|
||||
|
||||
/// Create a new empty board
|
||||
#[allow(clippy::new_without_default)]
|
||||
pub const fn new() -> Self {
|
||||
Self {
|
||||
white_board: BitBoard::new(),
|
||||
|
||||
Reference in New Issue
Block a user