switch coordinates to global 'Coord' type

This commit is contained in:
2025-02-26 23:45:58 -05:00
parent a10b762b39
commit 7ec8a66a4e
10 changed files with 63 additions and 50 deletions

View File

@@ -1,4 +1,7 @@
use super::{board::Board, misc::get_index};
use super::{
board::{Board, Coord},
misc::get_index,
};
use const_fn::const_fn;
use static_assertions::const_assert;
@@ -24,7 +27,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);
const_assert!(std::mem::size_of::<BitBoard>() * 8 >= Board::BOARD_AREA as usize);
impl BitBoard {
#[cfg(feature = "bitvec")]
@@ -40,13 +43,13 @@ impl BitBoard {
}
#[const_fn(cfg(not(feature = "bitvec")))]
pub const fn get(&self, row: usize, col: usize) -> bool {
self.get_by_index(get_index(row, col))
pub const fn get(&self, row: Coord, col: Coord) -> bool {
self.get_by_index(get_index(row, col) as usize)
}
#[const_fn(cfg(not(feature = "bitvec")))]
pub const fn set(&mut self, row: usize, col: usize, value: bool) {
self.set_by_index(get_index(row, col), value);
pub const fn set(&mut self, row: Coord, col: Coord, value: bool) {
self.set_by_index(get_index(row, col) as usize, value);
}
#[cfg(not(feature = "bitvec"))]