aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2023-02-27 01:18:30 +0300
committereug-vs <eugene@eug-vs.xyz>2023-02-27 01:18:30 +0300
commitb3b63041b6920fdf3dab79d8c81bfda33fcf8012 (patch)
tree174addbf3e600b77891b3e6d221406b3fe4d6c38
parentbe303cc8e9b946acef773eaaf010ccaf9bbd3856 (diff)
downloadchessnost-b3b63041b6920fdf3dab79d8c81bfda33fcf8012.tar.gz
feat: print mate in X information in UCI
-rw-r--r--src/grossmeister/search.rs10
1 files changed, 7 insertions, 3 deletions
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;
}