diff options
-rw-r--r-- | src/board/engine.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/board/engine.rs b/src/board/engine.rs index 2ebbd7d..a710efb 100644 --- a/src/board/engine.rs +++ b/src/board/engine.rs @@ -267,6 +267,7 @@ impl Board { return (self.quiscence(alpha, beta), principal_variation); } + let mut legal_move_found = false; for mov in moves { let ep_target_before = self.ep_target.clone(); let castling_rights_before = self.castling_rights.clone(); @@ -274,6 +275,7 @@ impl Board { let captured_piece = self.make_move(mov); if !self.is_king_in_check(color) { + legal_move_found = true; let (mut score, mut subtree_pv) = self.negamax_search(-beta, -alpha, depth_left - 1, deadline); score *= -1.; self.unmake_move(mov, captured_piece, ep_target_before, castling_rights_before, hash_before); @@ -321,7 +323,7 @@ impl Board { } } - if principal_variation.len() == 0 { + if !legal_move_found { if self.is_king_in_check(color) { return (-VALUE_WIN, principal_variation); } |