impl propegation
This commit is contained in:
parent
3ab0f4bb5f
commit
a64d6b143f
31
src/repr.rs
31
src/repr.rs
@ -50,16 +50,19 @@ impl Board {
|
||||
|
||||
for i_range in i_ranges {
|
||||
let mut chain_length: usize = 0;
|
||||
for new_i in i_range {
|
||||
for new_i in i_range.clone() {
|
||||
match self.get(new_i, j) {
|
||||
Some(piece) => {
|
||||
if piece == &starting_color {
|
||||
if chain_length > 0 {
|
||||
todo!("matching end")
|
||||
// fill all opposite colors with this color
|
||||
i_range.get(..chain_length).unwrap().iter().for_each(|i_o| {
|
||||
self.place_and_prop_unchecked(*i_o, j, starting_color)
|
||||
});
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
todo!("add to the chain");
|
||||
chain_length += 1;
|
||||
}
|
||||
}
|
||||
None => break,
|
||||
@ -68,10 +71,26 @@ impl Board {
|
||||
}
|
||||
|
||||
for j_range in j_ranges {
|
||||
for new_j in j_range {}
|
||||
let mut chain_length: usize = 0;
|
||||
for new_j in j_range.clone() {
|
||||
match self.get(i, new_j) {
|
||||
Some(piece) => {
|
||||
if piece == &starting_color {
|
||||
if chain_length > 0 {
|
||||
// fill all opposite colors with this color
|
||||
j_range.get(..chain_length).unwrap().iter().for_each(|j_o| {
|
||||
self.place_and_prop_unchecked(i, *j_o, starting_color)
|
||||
});
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
chain_length += 1;
|
||||
}
|
||||
}
|
||||
None => break,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
todo!("propegation is not implemented");
|
||||
}
|
||||
|
||||
fn place_and_prop_unchecked(&mut self, i: usize, j: usize, piece: Piece) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user