simplify PosMap + BoardValueMap logic
This commit is contained in:
parent
abee9447ab
commit
8719d31c38
@ -20,7 +20,6 @@ impl BoardValueMap {
|
|||||||
|
|
||||||
/// Weights from: https://repub.eur.nl/pub/7142/ei2005-47.pdf
|
/// Weights from: https://repub.eur.nl/pub/7142/ei2005-47.pdf
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let mut map = PosMap::new();
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Board::BOARD_SIZE,
|
Board::BOARD_SIZE,
|
||||||
8,
|
8,
|
||||||
@ -37,11 +36,6 @@ impl BoardValueMap {
|
|||||||
[-20, -50, -2, -2, -2, -2, -50, -20],
|
[-20, -50, -2, -2, -2, -2, -50, -20],
|
||||||
[100, -20, 10, 5, 5, 10, -20, 100],
|
[100, -20, 10, 5, 5, 10, -20, 100],
|
||||||
];
|
];
|
||||||
|
Self(PosMap::from(POSITION_VALUES))
|
||||||
for (i, j) in Board::all_positions() {
|
|
||||||
map.set(i, j, POSITION_VALUES[i as usize][j as usize])
|
|
||||||
}
|
|
||||||
|
|
||||||
Self(map)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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
|
/// Creates a lookup map for adjacencies and chains from each position on the board
|
||||||
pub fn gen_adj_lookup() -> PosMap<ChainCollection> {
|
pub fn gen_adj_lookup() -> PosMap<ChainCollection> {
|
||||||
PosMap(
|
PosMap(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user