change iterator for board_value

This commit is contained in:
Simon Gardling 2025-02-21 19:53:11 -05:00
parent 6e1e8dac11
commit ff8211709d
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D

View File

@ -6,12 +6,13 @@ impl BoardValueMap {
pub fn board_value(&self, board: &Board, color: Piece) -> i64 { pub fn board_value(&self, board: &Board, color: Piece) -> i64 {
Board::all_positions() Board::all_positions()
.filter_map(|(i, j)| board.get(i, j).map(|p| (i, j, p))) .filter_map(|(i, j)| board.get(i, j).map(|p| (i, j, p)))
.map(|(i, j, pos_p)| { .map(|(i, j, pos_p)| (*self.0.get(i, j), pos_p))
let mut value = *self.0.get(i, j); .map(|(value, pos_p)| {
if pos_p != color { if pos_p != color {
// enemy has position // enemy has position
value = -value; return -value;
} }
// target has position
value value
}) })
.sum() .sum()