diff --git a/src/engine/context.rs b/src/engine/context.rs index c6d669a8..bb987f58 100644 --- a/src/engine/context.rs +++ b/src/engine/context.rs @@ -38,6 +38,7 @@ pub struct SearchContext { pub uci_debug: bool, pub ponder_mode: bool, pub soft_nodes: bool, + pub search_noise: bool, pub syzygy_enabled: bool, pub syzygy_probe_limit: u32, pub syzygy_probe_depth: i8, @@ -91,6 +92,7 @@ impl SearchContext { uci_debug: false, ponder_mode: false, soft_nodes: false, + search_noise: false, syzygy_enabled: false, syzygy_probe_limit: 0, syzygy_probe_depth: 0, diff --git a/src/engine/search/movepick.rs b/src/engine/search/movepick.rs index 65eaccaf..6e5f0f97 100644 --- a/src/engine/search/movepick.rs +++ b/src/engine/search/movepick.rs @@ -6,6 +6,7 @@ use crate::utils::assert_fast; use crate::utils::bithelpers::BitHelpers; use crate::utils::dev; use crate::utils::panic_fast; +use crate::utils::rand; use crate::MoveScores; use crate::Moves; use std::mem::MaybeUninit; @@ -332,7 +333,11 @@ fn assign_quiet_scores(context: &SearchContext, state: &mut MoveGenState, start_ continue; } - let value = context.htable.get(r#move.get_from(), r#move.get_to(), MOVEORD_HISTORY_MOVE) as i16; + let mut value = context.htable.get(r#move.get_from(), r#move.get_to(), MOVEORD_HISTORY_MOVE) as i16; + if context.search_noise { + value = i16::clamp(value + rand::i16(-5..5), 0, MOVEORD_HISTORY_MOVE as i16); + } + state.move_scores[move_index].write(value + MOVEORD_HISTORY_MOVE_OFFSET); } else if r#move.is_promotion() { state.move_scores[move_index].write(match r#move.get_promotion_piece() { diff --git a/src/interface/uci.rs b/src/interface/uci.rs index 687d16a2..0a9c0252 100644 --- a/src/interface/uci.rs +++ b/src/interface/uci.rs @@ -117,6 +117,7 @@ pub fn run() { #[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)); } @@ -388,6 +389,7 @@ fn handle_go(params: &[String], state: &UciState) { let syzygy_probe_limit = options_lock["SyzygyProbeLimit"].value.parse::().unwrap(); let syzygy_probe_depth = options_lock["SyzygyProbeDepth"].value.parse::().unwrap(); let soft_nodes = options_lock["Soft Nodes"].value.parse::().unwrap(); + let search_noise = options_lock["Search Noise"].value.parse::().unwrap(); #[cfg(not(feature = "dev"))] let search_params = SearchParams::default(); @@ -456,6 +458,7 @@ fn handle_go(params: &[String], state: &UciState) { context_lock.uci_debug = debug_mode; context_lock.ponder_mode = ponder_mode; context_lock.soft_nodes = soft_nodes; + context_lock.search_noise = search_noise; context_lock.syzygy_enabled = syzygy_enabled; context_lock.syzygy_probe_limit = syzygy_probe_limit; context_lock.syzygy_probe_depth = syzygy_probe_depth;