aboutsummaryrefslogtreecommitdiff
path: root/src/board
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2023-01-26 16:33:29 +0300
committereug-vs <eugene@eug-vs.xyz>2023-01-26 16:33:29 +0300
commit5237987cf62f8e031a979ba7945f11c710c28c57 (patch)
tree5c0169125882905ba4e00c8bdad824b2b3b48272 /src/board
parent7755ec638a1fbef2bb87f7cf0378e01dc650c17c (diff)
downloadchessnost-5237987cf62f8e031a979ba7945f11c710c28c57.tar.gz
feat: prioritize winning captures in move ordering
Diffstat (limited to 'src/board')
-rw-r--r--src/board/engine.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/board/engine.rs b/src/board/engine.rs
index 8bd409b..1d01e06 100644
--- a/src/board/engine.rs
+++ b/src/board/engine.rs
@@ -109,6 +109,7 @@ impl Board {
}
/// Evaluate move for move ordering, prioritizing efficient captures
+ /// where low-value pieces capture high-value pieces
fn eval_move(&self, m: Move) -> f32 {
let [source_eval, target_eval] = [m.source, m.target]
.map(|sq| self.piece_by_square(sq))
@@ -118,7 +119,7 @@ impl Board {
None => 0.,
}
});
- source_eval - target_eval
+ 2. * target_eval - source_eval
}
pub fn negamax_search(&mut self, mut alpha: f32, beta: f32, depth_left: u8, deadline: Instant) -> (f32, Vec<Move>) {
@@ -130,7 +131,7 @@ impl Board {
moves.sort_unstable_by(|a, b| {
let a_eval = self.eval_move(*a);
let b_eval = self.eval_move(*b);
- a_eval.total_cmp(&b_eval)
+ a_eval.total_cmp(&b_eval).reverse()
});
match self.transposition_table[(self.hash % TTABLE_SIZE) as usize] {
@@ -210,7 +211,7 @@ impl Board {
moves.sort_unstable_by(|a, b| {
let a_eval = self.eval_move(*a);
let b_eval = self.eval_move(*b);
- a_eval.total_cmp(&b_eval)
+ a_eval.total_cmp(&b_eval).reverse()
});
match self.transposition_table[(self.hash % TTABLE_SIZE) as usize] {