diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/board/engine.rs | 9 | ||||
-rw-r--r-- | src/board/mod.rs | 21 |
2 files changed, 8 insertions, 22 deletions
diff --git a/src/board/engine.rs b/src/board/engine.rs index 88ae77a..d550418 100644 --- a/src/board/engine.rs +++ b/src/board/engine.rs @@ -33,7 +33,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).unwrap(); + let captured_piece = self.make_move(mov); // King can not be in check after our own move if !self.is_king_in_check(color) { if depth == 1 { @@ -150,10 +150,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 = match self.make_move(mov) { - Ok(piece) => piece, - Err(err) => panic!("Handle me [{:?}]", err), - }; + let captured_piece = self.make_move(mov); if !self.is_king_in_check(color) { let (mut score, mut subtree_pv) = self.negamax_search(-beta, -alpha, depth_left - 1, deadline); @@ -223,7 +220,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).unwrap(); + let captured_piece = self.make_move(*mov); if !self.is_king_in_check(color) { let evaluation = -self.quiscence(-beta, -alpha); diff --git a/src/board/mod.rs b/src/board/mod.rs index 67f7264..84d77fb 100644 --- a/src/board/mod.rs +++ b/src/board/mod.rs @@ -77,11 +77,6 @@ const PIECE_CHARS: [&str; 12] = [ "♙", "♘", "♗", "♖", "♕", "♔", ]; -#[derive(Debug)] -pub enum MakeMoveError { - PieceNotFound(String), -} - #[allow(unused)] impl Board { @@ -500,7 +495,7 @@ impl Board { /// *Blindlessly* apply a move without any validation /// Move should be validated beforehand - pub fn make_move(&mut self, mov: Move) -> Result<Option<PieceType>,MakeMoveError> { + pub fn make_move(&mut self, mov: Move) -> Option<PieceType> { let move_source_bb = mov.source.to_bitboard(); let move_target_bb = mov.target.to_bitboard(); @@ -523,12 +518,8 @@ impl Board { self.pieces[pawn_type as usize] ^= captured_square.to_bitboard(); self.hash ^= self.zobrist_seed[pawn_type as usize* 12 + captured_square as usize]; Some(pawn_type) - } - None => { - return Err(MakeMoveError::PieceNotFound( - String::from("Pawn captured by En Passant was not found") - )) - } + }, + None => panic!("Pawn captured by En Passant was not found"), } } @@ -547,9 +538,7 @@ impl Board { }, None => { self.print(); - return Err(MakeMoveError::PieceNotFound( - String::from("Source piece not found") - )) + panic!("{:?} is malformed: source piece not found", mov); } }; @@ -620,7 +609,7 @@ impl Board { self.ply += 1; self.hash ^= self.zobrist_seed[780]; - Ok(captured_piece) + captured_piece } /// Completely reverse make_move as if it never happened |