aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2023-08-22 20:01:31 +0300
committereug-vs <eugene@eug-vs.xyz>2023-08-22 20:01:31 +0300
commit50e9cdcd6977c09aa8c2aba1059a3d0dacd80d51 (patch)
tree8731d58d0964b4058493191212584083f1db8a3b
parentb5aecc2b3461582e2a23e57043751bac40c062dc (diff)
downloadchessnost-50e9cdcd6977c09aa8c2aba1059a3d0dacd80d51.tar.gz
feat: count the number of pawn islands
-rw-r--r--src/grossmeister/evaluation.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/grossmeister/evaluation.rs b/src/grossmeister/evaluation.rs
index b7060ba..29c1128 100644
--- a/src/grossmeister/evaluation.rs
+++ b/src/grossmeister/evaluation.rs
@@ -162,6 +162,15 @@ impl Grossmeister {
(behind_pawns & (king | king.west_one() | king.east_one())).pop_count() as f32
}
+ /// Count the number of pawn islands of given color
+ pub fn pawn_islands(&self, color: Color) -> f32 {
+ let pawns = self.board.pieces_by_color(color)[Piece::Pawn as usize];
+ let fileset = pawns.nort_fill().sout_fill();
+ // Does not matter west/east, each island has both sides
+ let islands_west_files = fileset & !fileset.east_one();
+ islands_west_files.pop_count() as f32
+ }
+
// Returns a value in [0, 240] representing how
// much material is left in the game
// Note: not related to actual material counting
@@ -230,15 +239,18 @@ impl Grossmeister {
let material_advantage = self.material(color) - self.material(opponent_color);
let mobility_advantage = self.mobility(color) - self.mobility(opponent_color);
let pawn_shield_advantage = self.pawn_shield(color) - self.pawn_shield(opponent_color);
+ let pawn_islands_advantage = self.pawn_islands(opponent_color) - self.pawn_islands(color);
let middlegame_eval =
mobility_advantage * 0.05 +
pawn_shield_advantage * 0.15 +
+ pawn_islands_advantage * 0.10 +
(self.pst_bonus(color, false) - self.pst_bonus(opponent_color, false));
let endgame_eval =
mobility_advantage * 0.03 +
pawn_shield_advantage * 0.20 +
+ pawn_islands_advantage * 0.15 +
(self.pst_bonus(color, true) - self.pst_bonus(opponent_color, true));
let phase = self.phase();