Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat non-winning captures as unfavorable in quiescence search #57

Merged
merged 1 commit into from
Aug 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/search/alphabeta.rs
Original file line number Diff line number Diff line change
@@ -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"))]
8 changes: 4 additions & 4 deletions src/search/ordering.rs
Original file line number Diff line number Diff line change
@@ -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<Move>) -> [i32; MAX_MOVES] {
pub fn build_ordering(&self, moves: &MoveList, tt_move: Option<Move>, 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<Move>, continuations: &[FullMove; 2]) -> i32 {
fn get_move_rating(&self, mv: Move, tt_move: Option<Move>, 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 {
2 changes: 1 addition & 1 deletion src/search/quiescence.rs
Original file line number Diff line number Diff line change
@@ -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() {