From 5237987cf62f8e031a979ba7945f11c710c28c57 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Thu, 26 Jan 2023 16:33:29 +0300 Subject: feat: prioritize winning captures in move ordering --- src/board/engine.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') 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) { @@ -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] { -- cgit v1.2.3