diff --git a/src/logic/board_value.rs b/src/logic/board_value.rs index 61b82e7..8cb7fbf 100644 --- a/src/logic/board_value.rs +++ b/src/logic/board_value.rs @@ -20,7 +20,6 @@ impl BoardValueMap { /// Weights from: https://repub.eur.nl/pub/7142/ei2005-47.pdf pub fn new() -> Self { - let mut map = PosMap::new(); assert_eq!( Board::BOARD_SIZE, 8, @@ -37,11 +36,6 @@ impl BoardValueMap { [-20, -50, -2, -2, -2, -2, -50, -20], [100, -20, 10, 5, 5, 10, -20, 100], ]; - - for (i, j) in Board::all_positions() { - map.set(i, j, POSITION_VALUES[i as usize][j as usize]) - } - - Self(map) + Self(PosMap::from(POSITION_VALUES)) } } diff --git a/src/repr/chains.rs b/src/repr/chains.rs index 0e32ef1..63b8d15 100644 --- a/src/repr/chains.rs +++ b/src/repr/chains.rs @@ -49,6 +49,20 @@ impl PosMap { } } +type PosMapOrig = [[T; Board::BOARD_SIZE as usize]; Board::BOARD_SIZE as usize]; + +impl From> for PosMap { + fn from(value: PosMapOrig) -> 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 { PosMap(