diff options
author | eug-vs <eugene@eug-vs.xyz> | 2023-01-26 19:19:26 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2023-01-26 19:19:26 +0300 |
commit | 73db3fa8950d53008467ff5925010e2322e19e77 (patch) | |
tree | 1f9d0505d5d0b24132f99910a10b87ec7283ce2a | |
parent | e7acc49c4891618f9a85427689f34eb807556e9c (diff) | |
download | chessnost-73db3fa8950d53008467ff5925010e2322e19e77.tar.gz |
feat: correctly evaluate pawns at higher ranks
-rw-r--r-- | src/board/engine.rs | 26 |
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 } |