From b3b63041b6920fdf3dab79d8c81bfda33fcf8012 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Mon, 27 Feb 2023 01:18:30 +0300 Subject: feat: print mate in X information in UCI --- src/grossmeister/search.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/grossmeister') diff --git a/src/grossmeister/search.rs b/src/grossmeister/search.rs index cd9389d..5c03887 100644 --- a/src/grossmeister/search.rs +++ b/src/grossmeister/search.rs @@ -133,8 +133,12 @@ impl Grossmeister { } } - if !legal_move_found && self.board.is_king_in_check(color) { - return (-VALUE_WIN, principal_variation); + if !legal_move_found { + if self.board.is_king_in_check(color) { + return (-VALUE_WIN, principal_variation); + } else { + return (0.0, principal_variation); + } } (alpha, principal_variation) @@ -208,7 +212,7 @@ impl Grossmeister { let search_result = self.negamax_search(alpha, beta, depth, &mut root_killers); if search_result.0.abs() >= VALUE_WIN { - // TODO: do a mate search to print mate in X + println!("info mate {:.0}", (search_result.1.len() as f32 / 2.0).ceil(), ); result = Some(search_result); break; } -- cgit v1.2.3