From 34faf4abf56502e97fdeaf4a0d825cff75085b61 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sun, 29 Jan 2023 15:37:38 +0300 Subject: fix: correctly process cutoffs in i-deepening --- src/board/engine.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/board/engine.rs b/src/board/engine.rs index da0f38b..d24b5bb 100644 --- a/src/board/engine.rs +++ b/src/board/engine.rs @@ -459,25 +459,28 @@ impl Board { println!("Finished depth({}) {:?} [{:?} left]", depth, search_result, deadline - Instant::now()); - if search_result.1.len() > 0 { - depth += 1; - gradual_widening_counter = 0; - alpha = search_result.0 - window_size; - beta = search_result.0 + window_size; - } else if search_result.0 <= alpha { // Alpha-cutoff + if search_result.0 <= alpha { // Alpha-cutoff println!("Alpha cutoff {} <= {:?}", search_result.0, (alpha, beta)); gradual_widening_counter += 1; beta = alpha; alpha = search_result.0 - window_size * 2.0f32.powi(gradual_widening_counter); continue; - } else if search_result.0 >= beta { // Beta-cutoff + } + if search_result.0 >= beta { // Beta-cutoff println!("Beta cutoff {:?} <= {}", (alpha, beta), search_result.0); gradual_widening_counter += 1; alpha = beta; beta = search_result.0 + window_size * 2.0f32.powi(gradual_widening_counter); continue; + } + + if search_result.1.len() > 0 { + depth += 1; + gradual_widening_counter = 0; + alpha = search_result.0 - window_size; + beta = search_result.0 + window_size; } else { - panic!("Can this ever be possible? (probably not)"); + panic!("Why the fuck no moves?"); } result = Some(search_result); -- cgit v1.2.3