diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/grossmeister/UCI.rs | 14 |
1 files 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); } |