what_if: only return Some if how_many_prop is above 0
This commit is contained in:
parent
45e1a05839
commit
7aebdc3c78
@ -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(());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user