initial BoardValueMap
This commit is contained in:
20
src/logic/board_value.rs
Normal file
20
src/logic/board_value.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use crate::repr::{Board, Piece, PosMap};
|
||||
|
||||
pub struct BoardValueMap(PosMap<f32>);
|
||||
|
||||
impl BoardValueMap {
|
||||
pub fn board_value(&self, board: &Board, color: Piece) -> f32 {
|
||||
let mut board_value: f32 = 0.0;
|
||||
for (i, j) in Board::all_positions() {
|
||||
if let Some(pos_p) = board.get(i, j) {
|
||||
let mut value = *self.0.get(i, j);
|
||||
if pos_p != color {
|
||||
// enemy has position
|
||||
value = -value;
|
||||
}
|
||||
board_value += value;
|
||||
}
|
||||
}
|
||||
board_value
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
mod board_value;
|
||||
mod future_moves;
|
||||
mod r#move;
|
||||
pub use future_moves::FutureMoves;
|
||||
|
||||
Reference in New Issue
Block a user