This commit is contained in:
Simon Gardling 2025-02-20 19:33:15 -05:00
parent d29095bc9d
commit 2011ae001b
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D
4 changed files with 11 additions and 51 deletions

33
Cargo.lock generated
View File

@ -129,17 +129,6 @@ version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"
[[package]]
name = "comptime"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed5e683f1f8879ac923fa7f69d180872f9bb8a417505c332f08fa6955f537dd2"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "console"
version = "0.15.10"
@ -442,7 +431,6 @@ version = "0.1.0"
dependencies = [
"arrayvec",
"bitvec",
"comptime",
"const_fn",
"criterion",
"either",
@ -638,7 +626,7 @@ checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.98",
"syn",
]
[[package]]
@ -659,17 +647,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "syn"
version = "1.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "syn"
version = "2.0.98"
@ -750,7 +727,7 @@ dependencies = [
"log",
"proc-macro2",
"quote",
"syn 2.0.98",
"syn",
"wasm-bindgen-shared",
]
@ -772,7 +749,7 @@ checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.98",
"syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
@ -933,7 +910,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.98",
"syn",
]
[[package]]
@ -944,5 +921,5 @@ checksum = "76331675d372f91bf8d17e13afbd5fe639200b73d01f0fc748bb059f9cca2db7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.98",
"syn",
]

View File

@ -29,8 +29,7 @@ bitvec = [ "dep:bitvec" ]
[dependencies]
arrayvec = "0.7"
bitvec = { version = "1", optional = true }
comptime = "1.0.0"
const_fn = "0.4.11"
const_fn = "0.4"
either = "1.13"
indicatif = "0.17"
lazy_static = "1.5"

View File

@ -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)
}

View File

@ -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(),