diff options
Diffstat (limited to 'src/board')
-rw-r--r-- | src/board/engine.rs | 2 | ||||
-rw-r--r-- | src/board/mod.rs | 13 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/board/engine.rs b/src/board/engine.rs index 10fb604..6491289 100644 --- a/src/board/engine.rs +++ b/src/board/engine.rs @@ -263,7 +263,7 @@ impl Board { let king_tropism_penalty = self.king_tropism(color) - self.king_tropism(opponent_color); material_advantage - + 0.1 * mobility_advantage + + 0.15 * mobility_advantage - 0.3 * pawn_structure_penalty + king_tropism_penalty * (opponent_material / 40.0) * 0.07 } 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 => { |