From da86a1dfdc5bf20ef3397a08aaa1dc7e9e1fdd81 Mon Sep 17 00:00:00 2001 From: Daniel Olsen Date: Wed, 6 Jan 2021 11:07:22 +0100 Subject: [PATCH] match --- src/main.rs | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/main.rs b/src/main.rs index 18b86b2..01a9c87 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,23 +10,28 @@ use rand::prelude::*; fn main() -> Result<(), &'static str> { - - let rng = StdRng::seed_from_u64(42); - let mut game = Game::new(2, rng)?; - game.fill()?; - println!("{:#?}", game); - game.do_move(GameMove(1, Tile::Red, 2))?; - game.do_move(GameMove(4, Tile::Red, 2))?; + let program = 2; - game.do_move(GameMove(2, Tile::Red, 1))?; + return match program { + 1 => { + let rng = StdRng::seed_from_u64(42); + let mut game = Game::new(2, rng)?; + game.fill()?; + println!("{:#?}", game); - println!("{}", count_options(game, 0, 2)); - + game.do_move(GameMove(1, Tile::Red, 2))?; + game.do_move(GameMove(4, Tile::Red, 2))?; - // calculate_options()?; + game.do_move(GameMove(2, Tile::Red, 1))?; - Ok(()) + println!("{}", count_options(game, 0, 2)); + + Ok(()) + }, + 2 => calculate_options(), + _ => Err("Not a valid program") + } } fn run(rng: StdRng) -> Result<(), &'static str> { @@ -109,4 +114,4 @@ fn count_options(game: Game, depth: u8, treshold: u8) -> u128 { }) .sum::()*/ -} \ No newline at end of file +}