From 2435458e158e7b075545cd5af88d634a31b5932c Mon Sep 17 00:00:00 2001 From: Daniel Olsen Date: Sun, 16 May 2021 12:39:57 +0200 Subject: [PATCH] make benchmark game static --- src/azul.rs | 33 +++++++++++++++++++++++++++++++++ src/main.rs | 18 ++++++------------ 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/src/azul.rs b/src/azul.rs index b17239c..c89a527 100644 --- a/src/azul.rs +++ b/src/azul.rs @@ -678,6 +678,39 @@ pub fn complicated() -> Result { Ok(game) } +pub fn some_game() -> Result { + let mut game = Game::new(2)?; + + let factories = &mut game.factories; + + factories[0].push(Tile::Blue); + factories[0].push(Tile::Blue); + factories[0].push(Tile::Yellow); + factories[0].push(Tile::Black); + + factories[1].push(Tile::Blue); + factories[1].push(Tile::Red); + factories[1].push(Tile::Red); + factories[1].push(Tile::Red); + + factories[2].push(Tile::Blue); + factories[2].push(Tile::Red); + factories[2].push(Tile::Black); + factories[2].push(Tile::Teal); + + factories[3].push(Tile::Blue); + factories[3].push(Tile::Red); + factories[3].push(Tile::Black); + factories[3].push(Tile::Teal); + + factories[4].push(Tile::Yellow); + factories[4].push(Tile::Yellow); + factories[4].push(Tile::Black); + factories[4].push(Tile::Teal); + + Ok(game) +} + #[test] fn connected() -> Result<(), String> { let mut board = Board::default(); diff --git a/src/main.rs b/src/main.rs index f6b9b23..8a6869a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,24 +22,18 @@ fn main() -> Result<(), &'static str> { return match program { 1 => { - let mut rng = StdRng::seed_from_u64(42); - let mut game = Game::new(2)?; - game.fill(StdRng::from_rng(&mut rng).expect("rng error"))?; - //println!("{:#?}", game); + let mut game = some_game()?; - game.do_move(GameMove(1, Tile::Blue, 2))?; - game.do_move(GameMove(3, Tile::Yellow, 2))?; + game.do_move(GameMove(2, Tile::Red, 3))?; + game.do_move(GameMove(5, Tile::Yellow, 2))?; - game.do_move(GameMove(0, Tile::Teal, 4))?; - game.do_move(GameMove(5, Tile::Teal, 4))?; + game.do_move(GameMove(3, Tile::Blue, 2))?; + game.do_move(GameMove(0, Tile::Black, 4))?; - //game.do_move(GameMove(4, Tile::Yellow, 1))?; + game.do_move(GameMove(5, Tile::Black, 1))?; //game.do_move(GameMove(0, Tile::Blue, 3))?; - - // println!("{:#?}", game); println!("{}", count_options(game, 1, 2)); - Ok(()) }, 2 => calculate_options(),