changes
This commit is contained in:
10
src/agent.rs
10
src/agent.rs
@@ -14,7 +14,7 @@ pub struct ManualAgent {
|
||||
}
|
||||
|
||||
impl Agent for ManualAgent {
|
||||
fn next_move(&mut self, _: &Board) -> Option<(usize, usize)> {
|
||||
fn next_move(&mut self, board: &Board) -> Option<(usize, usize)> {
|
||||
let stdin = io::stdin();
|
||||
let mut input = String::new();
|
||||
println!("Your turn! ('Skip' to skip)");
|
||||
@@ -34,8 +34,12 @@ impl Agent for ManualAgent {
|
||||
.and_then(|x| -> Option<[usize; 2]> { x.try_into().ok() })
|
||||
.map(|x| (x[0], x[1]));
|
||||
|
||||
if got.is_some() {
|
||||
return got;
|
||||
if let Some(got) = got {
|
||||
if board.possible_moves(self.color).all(|x| x != got) {
|
||||
println!("Invalid move! Try again.");
|
||||
continue;
|
||||
}
|
||||
return Some(got);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user