change iterator for board_value
This commit is contained in:
parent
6e1e8dac11
commit
ff8211709d
@ -6,12 +6,13 @@ impl BoardValueMap {
|
||||
pub fn board_value(&self, board: &Board, color: Piece) -> i64 {
|
||||
Board::all_positions()
|
||||
.filter_map(|(i, j)| board.get(i, j).map(|p| (i, j, p)))
|
||||
.map(|(i, j, pos_p)| {
|
||||
let mut value = *self.0.get(i, j);
|
||||
.map(|(i, j, pos_p)| (*self.0.get(i, j), pos_p))
|
||||
.map(|(value, pos_p)| {
|
||||
if pos_p != color {
|
||||
// enemy has position
|
||||
value = -value;
|
||||
return -value;
|
||||
}
|
||||
// target has position
|
||||
value
|
||||
})
|
||||
.sum()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user