aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2023-01-28 02:08:11 +0300
committereug-vs <eugene@eug-vs.xyz>2023-01-28 02:08:11 +0300
commita7b6e6e687c327b8cd86350240a3b2c395b47af1 (patch)
tree892acc5a1e0ac30359011285dc84dc3c7ab410a3 /src
parent70315e4652bb49981108a9b920b95ab82a53edb7 (diff)
downloadchessnost-a7b6e6e687c327b8cd86350240a3b2c395b47af1.tar.gz
fix: correctly calculate king tropism
Diffstat (limited to 'src')
-rw-r--r--src/board/engine.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/board/engine.rs b/src/board/engine.rs
index ed533df..65851cf 100644
--- a/src/board/engine.rs
+++ b/src/board/engine.rs
@@ -153,7 +153,7 @@ impl Board {
}
/// Returns the weighted sum of distances from attacking pieces to a king
- /// The higher this value, the more likely the king is to be in danger
+ /// The higher this value, the safer is the king
pub fn king_tropism(&self, color: Color) -> f32 {
let mut result = 0.0;
@@ -169,7 +169,7 @@ impl Board {
(king_square.rank() as f32 - square.rank() as f32).abs() +
(king_square.file() as f32 - square.file() as f32).abs();
- result += distance * PieceType::from(piece_type).static_eval();
+ result += distance / PieceType::from(piece_type).static_eval();
}
}
}
@@ -195,7 +195,7 @@ impl Board {
let king_tropism_penalty = self.king_tropism(color) - self.king_tropism(opponent_color);
- material_advantage + 0.1 * mobility_advantage - 0.5 * pawn_structure_penalty - king_tropism_penalty * opponent_material / 3000.0
+ material_advantage + 0.1 * mobility_advantage - 0.5 * pawn_structure_penalty + king_tropism_penalty * opponent_material / 100.0
}
/// Evaluate move for move ordering, prioritizing efficient captures