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

Implement reverse futility pruning #650

Merged
merged 1 commit into from
Nov 17, 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
14 changes: 14 additions & 0 deletions lib/search/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@
(bounds.start.max(lower), bounds.end.min(upper))
}

/// An implementation of [reverse futility pruning].
///
/// [reverse futility pruning]: https://www.chessprogramming.org/Reverse_Futility_Pruning
fn rfp(&self, depth: Depth, ply: Ply) -> Score {
match (depth - ply).get() {
draft @ ..=6 => Score::new(100) * draft,
_ => Score::upper(),

Check warning on line 82 in lib/search/engine.rs

View check run for this annotation

Codecov / codecov/patch

lib/search/engine.rs#L82

Added line #L82 was not covered by tests
}
}

/// An implementation of [null move pruning].
///
/// [null move pruning]: https://www.chessprogramming.org/Null_Move_Pruning
Expand Down Expand Up @@ -187,6 +197,10 @@

if alpha >= beta || ply >= Ply::MAX {
return Ok(Pv::new(score, None));
} else if score - self.rfp(depth, ply) >= beta {
#[cfg(not(test))]
// The reverse futility pruning heuristic is not exact.
return Ok(Pv::new(score, None));
} else if !is_pv && !pos.is_check() && pos.pieces(pos.turn()).len() > 1 {
if let Some(d) = self.nmp(score, beta, depth, ply) {
let mut next = pos.clone();
Expand Down
Loading