diff options
author | eug-vs <eugene@eug-vs.xyz> | 2023-01-25 07:15:28 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2023-01-25 07:15:28 +0300 |
commit | 8dc121b0e08cd25fab3eacde9318d7adaac1f2a4 (patch) | |
tree | a4e1af09bb368704d47e5844efc3726e71791f8d /src/board/engine.rs | |
parent | a1ad1424bcbf0fd8fff2ce9c4048e88a58934f20 (diff) | |
download | chessnost-8dc121b0e08cd25fab3eacde9318d7adaac1f2a4.tar.gz |
refactor: return recoverable errors from make_move
Diffstat (limited to 'src/board/engine.rs')
-rw-r--r-- | src/board/engine.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/board/engine.rs b/src/board/engine.rs index 2c6e47a..4fe8652 100644 --- a/src/board/engine.rs +++ b/src/board/engine.rs @@ -32,7 +32,7 @@ impl Board { let ep_target_before = self.ep_target.clone(); let castling_rights_before = self.castling_rights.clone(); let hash_before = self.hash.clone(); - let captured_piece = self.make_move(mov); + let captured_piece = self.make_move(mov).unwrap(); // King can not be in check after our own move if !self.is_king_in_check(color) { if depth == 1 { @@ -135,7 +135,10 @@ impl Board { let ep_target_before = self.ep_target.clone(); let castling_rights_before = self.castling_rights.clone(); let hash_before = self.hash.clone(); - let captured_piece = self.make_move(mov); + let captured_piece = match self.make_move(mov) { + Ok(piece) => piece, + Err(err) => panic!("Handle me [{:?}]", err), + }; if !self.is_king_in_check(color) { let (mut score, mut subtree_pv) = self.negamax_search(-beta, -alpha, depth_left - 1); @@ -184,7 +187,7 @@ impl Board { let ep_target_before = self.ep_target.clone(); let castling_rights_before = self.castling_rights.clone(); let hash_before = self.hash.clone(); - let captured_piece = self.make_move(*mov); + let captured_piece = self.make_move(*mov).unwrap(); if !self.is_king_in_check(color) { let evaluation = -self.quiscence(-beta, -alpha); |