aboutsummaryrefslogtreecommitdiff
path: root/src/board
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2023-01-26 19:19:26 +0300
committereug-vs <eugene@eug-vs.xyz>2023-01-26 19:19:26 +0300
commit73db3fa8950d53008467ff5925010e2322e19e77 (patch)
tree1f9d0505d5d0b24132f99910a10b87ec7283ce2a /src/board
parente7acc49c4891618f9a85427689f34eb807556e9c (diff)
downloadchessnost-73db3fa8950d53008467ff5925010e2322e19e77.tar.gz
feat: correctly evaluate pawns at higher ranks
Diffstat (limited to 'src/board')
-rw-r--r--src/board/engine.rs26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/board/engine.rs b/src/board/engine.rs
index a4b72eb..06369f5 100644
--- a/src/board/engine.rs
+++ b/src/board/engine.rs
@@ -88,8 +88,30 @@ impl Board {
} else {
-1.
};
- let multiplier = piece_type.static_eval();
- eval += sign * multiplier * pop_count(*bitboard) as f32;
+
+ eval += sign * match piece_type {
+ PieceType::Pawn => {
+ serialize_bitboard(*bitboard).iter().fold(0., |acc, square| {
+ acc + match (*square).rank() {
+ 6 => 3.,
+ 5 => 2.,
+ _ => 1.,
+ }
+ })
+ }
+ PieceType::PawnBlack => {
+ serialize_bitboard(*bitboard).iter().fold(0., |acc, square| {
+ acc + match (*square).rank() {
+ 1 => 3.,
+ 2 => 2.,
+ _ => 1.,
+ }
+ })
+ }
+ _ => {
+ piece_type.static_eval() * pop_count(*bitboard) as f32
+ }
+ };
}
eval
}