fix: allowed moves infinite loop
This commit is contained in:
parent
38100a61b2
commit
6478f5043d
8 changed files with 160 additions and 64 deletions
|
|
@ -441,7 +441,7 @@ impl Board {
|
|||
let blocked = self.blocked(color, cmove.to).unwrap_or(true);
|
||||
// Check if there is a player's checker on the 'from' square
|
||||
let has_checker = self.get_checkers_color(cmove.from).unwrap_or(None) == Some(color);
|
||||
has_checker && !blocked
|
||||
(has_checker && !blocked) || cmove == &EMPTY_MOVE
|
||||
}
|
||||
|
||||
/// Return if there is a quarter filled by the color
|
||||
|
|
@ -651,6 +651,12 @@ mod tests {
|
|||
assert!(board.set(&Color::White, 23, -3).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn move_possible() {
|
||||
let board = Board::new();
|
||||
assert!(board.move_possible(&Color::White, &EMPTY_MOVE));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn get_color_fields() {
|
||||
let board = Board::new();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue