aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2023-02-01 01:38:39 +0300
committereug-vs <eugene@eug-vs.xyz>2023-02-01 01:38:39 +0300
commit7a8845f9d089d9b5b70c5842d1d77e157374ac75 (patch)
tree5c8cb3e225feda1507e4388523b313a61e44e111 /src
parent41389a25e6e2aac395810029cce070cddec6ae86 (diff)
downloadchessnost-7a8845f9d089d9b5b70c5842d1d77e157374ac75.tar.gz
feat: exclude pawncontrolled squares from mobility
Diffstat (limited to 'src')
-rw-r--r--src/board/engine.rs2
-rw-r--r--src/board/mod.rs13
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 => {