diff --git a/src/board.rs b/src/board.rs index 925130f..f9c558c 100644 --- a/src/board.rs +++ b/src/board.rs @@ -70,12 +70,14 @@ impl Board { } self_copy.place_unchecked(i, j, piece); let how_many_prop = self_copy.propegate_from(i, j); + if how_many_prop == 0 { + return None; + } Some((self_copy, how_many_prop)) } pub fn place(&mut self, i: usize, j: usize, piece: Piece) -> Result<(), String> { - let what_if_result = self.what_if(i, j, piece); - if let Some(what_if_result) = what_if_result { + if let Some(what_if_result) = self.what_if(i, j, piece) { if what_if_result.1 > 0 { *self = what_if_result.0; return Ok(());