Created
May 22, 2014 21:47
-
-
Save schmee/ac2403a9e5d4439ecc0c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn play(circles_move: |TicTacToe| -> TicTacToe, | |
crosses_move: |TicTacToe| -> TicTacToe) { | |
let mut game = tictactoe::TicTacToe::empty_board(); | |
game.print(); | |
while !game.is_game_over() { | |
match game.player() { | |
PlayerCircle => { | |
println!("Circles move: "); | |
game = circles_move(game); | |
} | |
PlayerCross => { | |
println!("Crosses move: "); | |
game = crosses_move(game); | |
} | |
} | |
game.print(); | |
} | |
match game.winner() { | |
Some(PlayerCircle) => println!("Circles won!"), | |
Some(PlayerCross) => println!("Crosses won!"), | |
None => println!("Game draw!") | |
} | |
} | |
fn make_random_move(game: TicTacToe) -> TicTacToe { | |
game.make_random_move() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment