From 6a92408ef0209e48c2a09ab3c7c33d0e5a8dddce Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sun, 26 Feb 2023 21:08:37 +0300 Subject: feat: finish very basic UCI implementation --- src/grossmeister/UCI.rs | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'src/grossmeister/UCI.rs') 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()); }, -- cgit v1.2.3