diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/board/engine.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/board/engine.rs b/src/board/engine.rs index 1d01e06..a4b72eb 100644 --- a/src/board/engine.rs +++ b/src/board/engine.rs @@ -271,6 +271,13 @@ impl Board { let search_result = self.negamax_search(alpha, beta, depth, deadline); println!("Finished depth({}) {:?} [{:?} left]", depth, search_result, deadline - Instant::now()); + if Instant::now() > deadline { + match result { + Some(r) => return r, + None => panic!("Could not find a move in time"), + } + } + if search_result.1.len() > 0 { depth += 1; alpha = search_result.0 - window_size; @@ -278,22 +285,16 @@ impl Board { } else if search_result.0 <= alpha { // Alpha-cutoff println!("Alpha cutoff {} <= {:?}", search_result.0, (alpha, beta)); alpha = search_result.0 - window_size; + continue; } else if search_result.0 >= beta { // Beta-cutoff println!("Beta cutoff {:?} <= {}", (alpha, beta), search_result.0); beta = search_result.0 + window_size; + continue; } else { panic!("Can this ever be possible? (probably not)"); } - if Instant::now() > deadline { - match result { - Some(r) => return r, - None => panic!("Could not find a move in time"), - } - } - result = Some(search_result); - } } } |