Skip to content

Instantly share code, notes, and snippets.

@schmee
Last active August 29, 2015 14:01
Show Gist options
  • Save schmee/bbab7b8ab00eed00e611 to your computer and use it in GitHub Desktop.
Save schmee/bbab7b8ab00eed00e611 to your computer and use it in GitHub Desktop.
fn make_human_move1(game: TicTacToe) -> TicTacToe {
let mut move = parse_move_from_stdin();
let new_game = game.make_move_from_input(move);
loop {
match new_game {
Some(g) => return g,
None => {
println!("Bad input / invalid move, try again:");
move = parse_move_from_stdin();
let new_game = game.make_move_from_input(move);
}
}
}
}
fn make_human_move2(game: TicTacToe) -> TicTacToe {
let mut move = parse_move_from_stdin();
let mut new_game = game.make_move_from_input(move);
loop {
match new_game {
Some(g) => return g,
None => {
println!("Bad input / invalid move, try again:");
move = parse_move_from_stdin();
new_game = game.make_move_from_input(move);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment