diff options
author | eug-vs <eugene@eug-vs.xyz> | 2023-02-26 19:46:11 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2023-02-26 19:56:17 +0300 |
commit | fe952d63dc26c787350c9b3259d037344241665b (patch) | |
tree | 90f23c8e4d1200e346f204acbb67e234e18e46ca | |
parent | 280fbc2acedcc5bbfcca141e610b3b37cf7d4397 (diff) | |
download | chessnost-fe952d63dc26c787350c9b3259d037344241665b.tar.gz |
feat: send infos from iterative deepening
-rw-r--r-- | src/grossmeister/mod.rs | 2 | ||||
-rw-r--r-- | src/grossmeister/search.rs | 42 |
2 files changed, 22 insertions, 22 deletions
diff --git a/src/grossmeister/mod.rs b/src/grossmeister/mod.rs index bd123d4..db9cb58 100644 --- a/src/grossmeister/mod.rs +++ b/src/grossmeister/mod.rs @@ -46,6 +46,6 @@ 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, true) + self.iterative_deepening(8) } } diff --git a/src/grossmeister/search.rs b/src/grossmeister/search.rs index 20e1dd9..2c2a296 100644 --- a/src/grossmeister/search.rs +++ b/src/grossmeister/search.rs @@ -1,7 +1,5 @@ use std::cmp::Ordering; -use std::sync::Arc; -use std::sync::atomic::AtomicBool; -use std::{time::Instant, f32::INFINITY}; +use std::f32::INFINITY; use crate::{moves::{Move, MoveKind}, board::io::IO}; @@ -192,7 +190,7 @@ impl Grossmeister { alpha } - pub fn iterative_deepening(&mut self, max_depth: u8, print: bool) -> (f32, Vec<Move>) { + pub fn iterative_deepening(&mut self, max_depth: u8) -> (f32, Vec<Move>) { let mut result = None; let mut depth = 1; let mut alpha = -INFINITY; @@ -201,11 +199,12 @@ impl Grossmeister { let mut gradual_widening_counter = 0; let mut root_killers: Vec<Move> = Vec::new(); - + println!("info depth 1"); while depth <= max_depth { - if print { - println!("\nSearching depth({}) in the window {:?}", depth, (alpha, beta)); + if self.debug { + println!("info string window {:?}", (alpha, beta)); } + let search_result = self.negamax_search(alpha, beta, depth, &mut root_killers); if search_result.0.abs() >= VALUE_WIN { @@ -213,32 +212,24 @@ impl Grossmeister { } if self.should_halt.load(std::sync::atomic::Ordering::Relaxed) { - if print { - println!("Aborting..."); + if self.debug { + println!("info string aborting"); } break; } - if print { - println!("Finished depth({}) {:?}", depth, search_result); - } - if search_result.0 <= alpha { // Alpha-cutoff - if print { - println!("Alpha cutoff {} <= {:?}", search_result.0, (alpha, beta)); - } gradual_widening_counter += 1; beta = alpha + window_size * 0.1; alpha = search_result.0 - window_size * 2.0f32.powi(gradual_widening_counter); + println!("info score upperbound {:.0}", beta * 100.0); continue; } if search_result.0 >= beta { // Beta-cutoff - if print { - println!("Beta cutoff {:?} <= {}", (alpha, beta), search_result.0); - } gradual_widening_counter += 1; alpha = beta - window_size * 0.1; beta = search_result.0 + window_size * 2.0f32.powi(gradual_widening_counter); + println!("info score lowerbound {:.0}", alpha * 100.0); continue; } @@ -247,11 +238,20 @@ impl Grossmeister { gradual_widening_counter = 0; alpha = search_result.0 - window_size; beta = search_result.0 + window_size; + + { + print!("info score cp {:.0} pv ", search_result.0 * 100.0); + for mov in &search_result.1 { + print!("{} ", mov); + } + println!(); + println!("info depth {}", depth); + } + + result = Some(search_result); } else { panic!("Why the fuck no moves?"); } - - result = Some(search_result); } match result { |