diff options
author | eug-vs <eugene@eug-vs.xyz> | 2023-01-29 00:36:31 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2023-01-29 01:00:50 +0300 |
commit | 754acbc83393ae8318f48add5eaf17633c53ed19 (patch) | |
tree | 70612e42984f881165191dd47666a1425e06f601 /src | |
parent | faec628945c6684d5eda72f7410f5029fdc3e34c (diff) | |
download | chessnost-754acbc83393ae8318f48add5eaf17633c53ed19.tar.gz |
refactor: exponentially grow windows on research
Diffstat (limited to 'src')
-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)"); |