diff --git a/src/engine/context.rs b/src/engine/context.rs index bb987f58..28dfac61 100644 --- a/src/engine/context.rs +++ b/src/engine/context.rs @@ -27,6 +27,7 @@ pub struct SearchContext { pub current_depth: i8, pub forced_depth: i8, pub max_nodes_count: u64, + pub max_soft_nodes_count: u64, pub max_move_time: u32, pub moves_to_go: u32, pub moves_to_search: Vec, @@ -81,6 +82,7 @@ impl SearchContext { current_depth: 1, forced_depth: 0, max_nodes_count: 0, + max_soft_nodes_count: 0, max_move_time: 0, moves_to_go: 0, moves_to_search: Vec::new(), @@ -163,7 +165,7 @@ impl Iterator for SearchContext { } // With soft nodes enabled, search is stopped after completing the depth instead aborting it in the middle - if self.soft_nodes && self.max_nodes_count > 0 && self.stats.nodes_count >= self.max_nodes_count { + if self.soft_nodes && self.max_soft_nodes_count > 0 && self.stats.nodes_count + self.stats.q_nodes_count >= self.max_soft_nodes_count { return None; } diff --git a/src/engine/search/runner.rs b/src/engine/search/runner.rs index 4aed8a93..c88c0571 100644 --- a/src/engine/search/runner.rs +++ b/src/engine/search/runner.rs @@ -115,7 +115,7 @@ fn run_internal( } } - if !context.soft_nodes && context.max_nodes_count != 0 { + if context.max_nodes_count != 0 { if context.stats.nodes_count + context.stats.q_nodes_count >= context.max_nodes_count { context.abort_flag.store(true, Ordering::Relaxed); return INVALID_SCORE; diff --git a/src/interface/uci.rs b/src/interface/uci.rs index 0a9c0252..bf2bb501 100644 --- a/src/interface/uci.rs +++ b/src/interface/uci.rs @@ -112,14 +112,12 @@ pub fn run() { options_lock.insert("SyzygyProbeLimit".to_string(), UciOption::new(5, "spin", 1, 9, 8)); options_lock.insert("SyzygyProbeDepth".to_string(), UciOption::new(6, "spin", 1, 32, 6)); options_lock.insert("Ponder".to_string(), UciOption::new(7, "check", false, false, false)); + options_lock.insert("Soft Nodes".to_string(), UciOption::new(50, "check", false, false, false)); + options_lock.insert("Search Noise".to_string(), UciOption::new(50, "check", false, false, false)); options_lock.insert("Clear Hash".to_string(), UciOption::new(8, "button", "", "", "")); #[cfg(feature = "dev")] - { - options_lock.insert("Soft Nodes".to_string(), UciOption::new(50, "check", false, false, false)); - options_lock.insert("Search Noise".to_string(), UciOption::new(50, "check", false, false, false)); - options_lock.insert("Crash Files".to_string(), UciOption::new(50, "check", false, false, false)); - } + options_lock.insert("Crash Files".to_string(), UciOption::new(50, "check", false, false, false)); #[cfg(feature = "dev")] { @@ -449,6 +447,7 @@ fn handle_go(params: &[String], state: &UciState) { context_lock.current_depth = 1; context_lock.forced_depth = forced_depth; context_lock.max_nodes_count = max_nodes_count; + context_lock.max_soft_nodes_count = max_nodes_count; context_lock.max_move_time = max_move_time; context_lock.moves_to_go = moves_to_go; context_lock.moves_to_search = moves_to_search.clone(); @@ -464,6 +463,10 @@ fn handle_go(params: &[String], state: &UciState) { context_lock.syzygy_probe_depth = syzygy_probe_depth; context_lock.stats = SearchStats::default(); + if soft_nodes { + context_lock.max_nodes_count *= 10; + } + context_lock.lines.clear(); context_lock.helper_contexts.write().unwrap().clear();