Skip to content

Late move reduction #44

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions engine/src/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ pub struct Opts {
/// Internal iterative deepening lower depth limit.
#[uci(kind = "spin", min = "5", max = "10", default = "5")]
pub iid_depth_lower_bound: Depth,
/// Late move reduction move number threshold.
#[uci(kind = "spin", min = "1", max = "256", default = "3")]
pub lmr_move_threshold: usize,

// Move ordering options:
//
Expand Down
9 changes: 8 additions & 1 deletion engine/src/search/negamax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::{
evaluate::Evaluate,
movelist::MoveVec,
newtypes::{Depth, Ply, Value},
opts::OPTS,
tt::{Bound, EntryWriterOpts},
};

Expand Down Expand Up @@ -78,7 +79,13 @@ impl Searcher<'_> {
for (mv_nr, mv) in moves.iter().map(|entry| entry.mv).enumerate() {
self.make_move(board, mv, &mut new_board, ply);

let value = self.pv_search::<PV>(&new_board, depth, alpha, beta, ply, mv_nr);
let mut new_depth = depth;

if mv_nr > OPTS.lmr_move_threshold && !new_board.in_check() {
new_depth = new_depth.decrement();
}

let value = self.pv_search::<PV>(&new_board, new_depth, alpha, beta, ply, mv_nr);

if self.should_stop() {
// If we're stopping, we don't trust the value, because it was likely cut off.
Expand Down