aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2023-02-24 17:45:39 +0300
committereug-vs <eugene@eug-vs.xyz>2023-02-24 17:45:39 +0300
commit40dffd88a018bb3757d7b0e3c97ba0ae4b4e8945 (patch)
tree4ef8f9a2df5e9adcf0e6e1774dafb7bbb2cd4d2e
parent10a68da1249931a6220ca06affa063c187836bbd (diff)
downloadchessnost-40dffd88a018bb3757d7b0e3c97ba0ae4b4e8945.tar.gz
fix: propagate t-table results after search
-rw-r--r--src/grossmeister/UCI.rs14
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);
}