diff options
Diffstat (limited to 'src/board')
-rw-r--r-- | src/board/engine.rs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/board/engine.rs b/src/board/engine.rs index 35aec11..8809378 100644 --- a/src/board/engine.rs +++ b/src/board/engine.rs @@ -323,7 +323,9 @@ impl Board { } if principal_variation.len() == 0 { - return (-VALUE_WIN, principal_variation); + if self.is_king_in_check(color) { + return (-VALUE_WIN, principal_variation); + } } (alpha, principal_variation) @@ -382,7 +384,7 @@ impl Board { let mut alpha = -INFINITY; let mut beta = INFINITY; let window_size = 0.25; - let mut gradual_widening_multiplier = 1.0; // Grows on cutoffs + let mut gradual_widening_counter = 0; while depth <= max_depth { let search_result = self.negamax_search(alpha, beta, depth, deadline); @@ -397,20 +399,20 @@ impl Board { } if search_result.1.len() > 0 { depth += 1; - gradual_widening_multiplier = 1.0; + gradual_widening_counter = 0; alpha = search_result.0 - window_size; beta = search_result.0 + window_size; } else if search_result.0 <= alpha { // Alpha-cutoff println!("Alpha cutoff {} <= {:?}", search_result.0, (alpha, beta)); - gradual_widening_multiplier *= 4.0; + gradual_widening_counter += 1; beta = alpha; - alpha = search_result.0 - window_size * gradual_widening_multiplier; + alpha = search_result.0 - window_size * 4.0f32.powi(gradual_widening_counter); continue; } else if search_result.0 >= beta { // Beta-cutoff println!("Beta cutoff {:?} <= {}", (alpha, beta), search_result.0); - gradual_widening_multiplier *= 4.0; + gradual_widening_counter += 1; alpha = beta; - beta = search_result.0 + window_size * gradual_widening_multiplier; + beta = search_result.0 + window_size * 4.0f32.powi(gradual_widening_counter); continue; } else { panic!("Can this ever be possible? (probably not)"); |