double prop is fake
This commit is contained in:
44
src/board.rs
44
src/board.rs
@@ -125,11 +125,11 @@ impl Board {
|
|||||||
let Some(history) = chain.get(..chain_length) else {
|
let Some(history) = chain.get(..chain_length) else {
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
captured += history.len();
|
||||||
|
|
||||||
// fill all opposite colors with this color
|
// fill all opposite colors with this color
|
||||||
for &(i_o, j_o) in history {
|
for &(i_o, j_o) in history {
|
||||||
self.place_unchecked(i_o, j_o, starting_color);
|
self.place_unchecked(i_o, j_o, starting_color);
|
||||||
captured += self.propegate_from(i_o, j_o) + 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// either the other pieces were replaced, or this was an invalid chain,
|
// either the other pieces were replaced, or this was an invalid chain,
|
||||||
@@ -241,46 +241,4 @@ mod test {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn double_prop() {
|
|
||||||
let mut board = Board::new();
|
|
||||||
assert_eq!(board.place(0, 0, Piece::Black), Ok(()));
|
|
||||||
|
|
||||||
assert_eq!(board.place(0, 1, Piece::White), Ok(()));
|
|
||||||
|
|
||||||
// -----------------
|
|
||||||
// |□|■| | | | | | |
|
|
||||||
// -----------------
|
|
||||||
// | | | | | | | | |
|
|
||||||
|
|
||||||
assert_eq!(board.place(1, 1, Piece::White), Ok(()));
|
|
||||||
|
|
||||||
// -----------------
|
|
||||||
// |□|■| | | | | | |
|
|
||||||
// -----------------
|
|
||||||
// | |■| | | | | | |
|
|
||||||
|
|
||||||
assert_eq!(board.place(2, 1, Piece::Black), Ok(()));
|
|
||||||
|
|
||||||
// -----------------
|
|
||||||
// |□|■| | | | | | |
|
|
||||||
// -----------------
|
|
||||||
// | |■| | | | | | |
|
|
||||||
// -----------------
|
|
||||||
// | |□| | | | | | |
|
|
||||||
|
|
||||||
assert_eq!(board.place(0, 2, Piece::Black), Ok(()));
|
|
||||||
|
|
||||||
// -----------------
|
|
||||||
// |□|□|□| | | | | |
|
|
||||||
// -----------------
|
|
||||||
// | |□| | | | | | |
|
|
||||||
// -----------------
|
|
||||||
// | |□| | | | | | |
|
|
||||||
|
|
||||||
assert_eq!(board.get(0, 1), &Some(Piece::Black));
|
|
||||||
|
|
||||||
assert_eq!(board.get(1, 1), &Some(Piece::Black));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user