diff options
author | eug-vs <eugene@eug-vs.xyz> | 2023-01-29 03:26:39 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2023-01-29 03:26:39 +0300 |
commit | 482cea1ebd9a43963fe0160fd081c97367534b7a (patch) | |
tree | 9ebf239ff8eaf9b6c0beb4c35a562cb4fd9daa57 /src/board | |
parent | 0d8860bd88c49641093434d2f96299b27a0ff641 (diff) | |
download | chessnost-482cea1ebd9a43963fe0160fd081c97367534b7a.tar.gz |
fix: correclty count legal moves
Diffstat (limited to 'src/board')
-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); } |