From 40dffd88a018bb3757d7b0e3c97ba0ae4b4e8945 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Fri, 24 Feb 2023 17:45:39 +0300 Subject: fix: propagate t-table results after search --- src/grossmeister/UCI.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/grossmeister/UCI.rs b/src/grossmeister/UCI.rs index 2c09a7b..3531a1e 100644 --- a/src/grossmeister/UCI.rs +++ b/src/grossmeister/UCI.rs @@ -10,7 +10,7 @@ const AUTHOR: &str = "Eugene Sokolov"; impl Grossmeister { pub fn start(&mut self) { let mut board = Board::new(); - let mut handle = None; + let mut search_handle = None; loop { let mut cmd = String::new(); @@ -47,11 +47,14 @@ impl Grossmeister { "go" => { match tokens[1] { "infinite" => { + // Clone current self and move it + // into thread to analyze a position let mut gm = self.clone(); let builder = Builder::new(); - handle = Some(builder.spawn(move || { + search_handle = Some(builder.spawn(move || { gm.analyze(board); + gm }).unwrap()); }, _ => todo!() @@ -59,8 +62,11 @@ impl Grossmeister { }, "stop" => { self.should_halt.store(true, std::sync::atomic::Ordering::Relaxed); - if let Some(hand) = handle.take() { - hand.join().unwrap(); + if let Some(hand) = search_handle.take() { + // Search returns new SELF that is more powerful + // because he evaluated many new positions and + // his transposition table is more saturated + *self = hand.join().unwrap(); } self.should_halt.store(false, std::sync::atomic::Ordering::Relaxed); } -- cgit v1.2.3