diff options
Diffstat (limited to 'src/board/mod.rs')
-rw-r--r-- | src/board/mod.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/board/mod.rs b/src/board/mod.rs index 8d12a12..fd0ff25 100644 --- a/src/board/mod.rs +++ b/src/board/mod.rs @@ -434,9 +434,20 @@ impl Board { pub fn mobility(&self, color: Color) -> f32 { let mut mobility = 0.; let opponent_occupancy = self.color_occupancy(color.flip()); - let empty = self.empty(); let player_pieces = self.pieces_by_color(color); + let opponent_pawns = match color { + Color::Black => self.pieces[PieceType::Pawn as usize], + Color::White => self.pieces[PieceType::PawnBlack as usize], + }; + + let pawn_attacked_squares = serialize_bitboard(opponent_pawns).iter().fold(0u64, |acc, square| { + acc | self.attacks.pawn[color.flip() as usize][*square as usize] + }); + + // Exclude squares controlled by enemy pawns from mobility + let empty = self.empty() & !pawn_attacked_squares; + for (piece_type, piece) in player_pieces.iter().enumerate() { match PieceType::from(piece_type) { PieceType::Pawn => { |