aboutsummaryrefslogtreecommitdiff
path: root/src/grossmeister
diff options
context:
space:
mode:
Diffstat (limited to 'src/grossmeister')
-rw-r--r--src/grossmeister/UCI.rs35
-rw-r--r--src/grossmeister/mod.rs9
-rw-r--r--src/grossmeister/search.rs9
3 files changed, 38 insertions, 15 deletions
diff --git a/src/grossmeister/UCI.rs b/src/grossmeister/UCI.rs
index 1e85b71..7c3cfb5 100644
--- a/src/grossmeister/UCI.rs
+++ b/src/grossmeister/UCI.rs
@@ -1,6 +1,6 @@
use std::{io::stdin, thread::Builder};
-use crate::{board::{Board, io::IO}, moves::Move, player::Player};
+use crate::{board::{Board, io::IO}, moves::Move};
use super::Grossmeister;
@@ -41,7 +41,7 @@ impl Grossmeister {
todo!()
}
"ucinewgame" => {
- todo!("What should we even do here?")
+ // TODO: clear transposition table
}
"position" => {
if let Some(token) = tokens.next() {
@@ -78,6 +78,18 @@ impl Grossmeister {
}
}
"go" => {
+ // Clone current self and move it
+ // into thread to analyze a position
+ let mut gm = self.clone();
+ let builder = Builder::new();
+
+ search_handle = Some(builder.spawn(move || {
+ gm.iterative_deepening(6);
+ gm
+ }).unwrap());
+
+ continue;
+
if let Some(token) = tokens.next() {
match token {
"searchmoves" => todo!(),
@@ -87,7 +99,22 @@ impl Grossmeister {
"winc" => todo!(),
"binc" => todo!(),
"movestogo" => todo!(),
- "depth" => todo!(),
+ "depth" => {
+ if let Some(depth) = tokens.next() {
+ let depth: u8 = depth.parse().unwrap();
+
+ // Clone current self and move it
+ // into thread to analyze a position
+ let mut gm = self.clone();
+ let builder = Builder::new();
+
+
+ search_handle = Some(builder.spawn(move || {
+ gm.iterative_deepening(depth);
+ gm
+ }).unwrap());
+ }
+ },
"nodes" => todo!(),
"mate" => todo!(),
"movetime" => todo!(),
@@ -98,7 +125,7 @@ impl Grossmeister {
let builder = Builder::new();
search_handle = Some(builder.spawn(move || {
- gm.analyze(gm.board);
+ gm.iterative_deepening(u8::MAX);
gm
}).unwrap());
},
diff --git a/src/grossmeister/mod.rs b/src/grossmeister/mod.rs
index db9cb58..3473d1e 100644
--- a/src/grossmeister/mod.rs
+++ b/src/grossmeister/mod.rs
@@ -1,6 +1,6 @@
use std::sync::{atomic::AtomicBool, Arc};
-use crate::{board::Board, player::Player, moves::Move};
+use crate::{board::Board, moves::Move};
use self::ttable::{TranspositionTable, TTABLE_SIZE};
mod ttable;
@@ -42,10 +42,3 @@ impl Grossmeister {
}
}
}
-
-impl Player for Grossmeister {
- fn analyze(&mut self, board: Board) -> (f32, Vec<Move>) {
- self.board = board; // Copy the board into GM's head
- self.iterative_deepening(8)
- }
-}
diff --git a/src/grossmeister/search.rs b/src/grossmeister/search.rs
index 2c2a296..def4305 100644
--- a/src/grossmeister/search.rs
+++ b/src/grossmeister/search.rs
@@ -199,8 +199,8 @@ impl Grossmeister {
let mut gradual_widening_counter = 0;
let mut root_killers: Vec<Move> = Vec::new();
- println!("info depth 1");
while depth <= max_depth {
+ println!("info depth {}", depth);
if self.debug {
println!("info string window {:?}", (alpha, beta));
}
@@ -245,7 +245,6 @@ impl Grossmeister {
print!("{} ", mov);
}
println!();
- println!("info depth {}", depth);
}
result = Some(search_result);
@@ -254,8 +253,12 @@ impl Grossmeister {
}
}
+
match result {
- Some(r) => r,
+ Some(r) => {
+ println!("bestmove {}", r.1[0]);
+ r
+ }
None => panic!("Could not find a move in time"),
}
}