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 {
|
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()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user