From f0ebb4b48052e166dcda6fd4a1b2e0dbed83ef06 Mon Sep 17 00:00:00 2001 From: Arseniy <93079612+codedeliveryservice@users.noreply.github.com> Date: Fri, 9 Aug 2024 06:32:01 +0300 Subject: [PATCH] Treat non-winning captures as unfavorable in qsearch Bench: 2563728 --- src/search/alphabeta.rs | 2 +- src/search/ordering.rs | 8 ++++---- src/search/quiescence.rs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/search/alphabeta.rs b/src/search/alphabeta.rs index c3a752a1..f2b774cd 100644 --- a/src/search/alphabeta.rs +++ b/src/search/alphabeta.rs @@ -108,7 +108,7 @@ impl super::SearchThread<'_> { let mut moves_played = 0; let mut quiets = MoveList::default(); let mut moves = self.board.generate_all_moves(); - let mut ordering = self.build_ordering(&moves, entry.map(|entry| entry.mv)); + let mut ordering = self.build_ordering(&moves, entry.map(|entry| entry.mv), 0); while let Some(mv) = moves.next(&mut ordering) { #[cfg(not(feature = "datagen"))] diff --git a/src/search/ordering.rs b/src/search/ordering.rs index 7777f3c6..8d272763 100644 --- a/src/search/ordering.rs +++ b/src/search/ordering.rs @@ -7,22 +7,22 @@ impl super::SearchThread<'_> { const BAD_NOISY: i32 = -100_000_000; /// Returns an array of move ratings for the specified move list. - pub fn build_ordering(&self, moves: &MoveList, tt_move: Option) -> [i32; MAX_MOVES] { + pub fn build_ordering(&self, moves: &MoveList, tt_move: Option, threshold: i32) -> [i32; MAX_MOVES] { let continuations = [1, 2].map(|ply| self.board.tail_move(ply)); let mut ordering = [0; MAX_MOVES]; for index in 0..moves.len() { - ordering[index] = self.get_move_rating(moves[index], tt_move, &continuations); + ordering[index] = self.get_move_rating(moves[index], tt_move, threshold, &continuations); } ordering } /// Returns the rating of the specified move. - fn get_move_rating(&self, mv: Move, tt_move: Option, continuations: &[FullMove; 2]) -> i32 { + fn get_move_rating(&self, mv: Move, tt_move: Option, threshold: i32, continuations: &[FullMove; 2]) -> i32 { if Some(mv) == tt_move { return Self::HASH_MOVE; } if mv.is_capture() { - let base = if self.see(mv, 0) { Self::GOOD_NOISY } else { Self::BAD_NOISY }; + let base = if self.see(mv, threshold) { Self::GOOD_NOISY } else { Self::BAD_NOISY }; return base + self.mvv_lva(mv); } if self.killers[self.ply] == mv { diff --git a/src/search/quiescence.rs b/src/search/quiescence.rs index c1943aa5..73061922 100644 --- a/src/search/quiescence.rs +++ b/src/search/quiescence.rs @@ -53,7 +53,7 @@ impl super::SearchThread<'_> { let mut best_score = eval; let mut moves = self.board.generate_capture_moves(); - let mut ordering = self.build_ordering(&moves, None); + let mut ordering = self.build_ordering(&moves, None, 1); while let Some(mv) = moves.next(&mut ordering) { if !mv.is_capture() {