simplify PosMap + BoardValueMap logic

This commit is contained in:
2025-02-26 23:58:52 -05:00
parent abee9447ab
commit 8719d31c38
2 changed files with 15 additions and 7 deletions

View File

@@ -49,6 +49,20 @@ impl<T: Default> PosMap<T> {
}
}
type PosMapOrig<T> = [[T; Board::BOARD_SIZE as usize]; Board::BOARD_SIZE as usize];
impl<T: Default + Copy> From<PosMapOrig<T>> for PosMap<T> {
fn from(value: PosMapOrig<T>) -> Self {
let mut new = Self::new();
for i in 0..Board::BOARD_SIZE {
for j in 0..Board::BOARD_SIZE {
new.set(i, j, value[i as usize][j as usize]);
}
}
new
}
}
/// Creates a lookup map for adjacencies and chains from each position on the board
pub fn gen_adj_lookup() -> PosMap<ChainCollection> {
PosMap(