From de62d560ce5bf878f6262fa159e73cc65ce72683 Mon Sep 17 00:00:00 2001 From: Martin HART Date: Wed, 4 Nov 2020 18:10:42 +0100 Subject: [PATCH 1/2] Add flag in order to generate a random world --- src/main.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main.rs b/src/main.rs index 22feaca..0075f30 100644 --- a/src/main.rs +++ b/src/main.rs @@ -239,6 +239,12 @@ fn main() -> Result<(), Box> { .takes_value(true) .help("Configuration file"), ) + .arg( + Arg::with_name("random-world") + .long("random-world") + .takes_value(false) + .help("Generate random world"), + ) .get_matches(); let raw_conf = open_file(matches.value_of("file").unwrap_or("two_robots.txt"))?; From 77d94524334c0749bb43ab0b67a0b823ba9690d9 Mon Sep 17 00:00:00 2001 From: Martin HART Date: Wed, 4 Nov 2020 21:43:02 +0100 Subject: [PATCH 2/2] What the hell ! FUCKING LIB ! --- src/main.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 0075f30..c316356 100644 --- a/src/main.rs +++ b/src/main.rs @@ -250,7 +250,11 @@ fn main() -> Result<(), Box> { let raw_conf = open_file(matches.value_of("file").unwrap_or("two_robots.txt"))?; let mut robot_pool: Vec = Vec::new(); - let world: world::World = parse_config(raw_conf, &mut robot_pool)?; + let world: world::World = match matches.value_of("random-world") { + None => parse_config(raw_conf, &mut robot_pool)?, + Some(_) => world::random_world(), + }; + let mut hash: HashMap = HashMap::new(); create_hash_map(&robot_pool, &mut hash); println!("World {{ x_max = {}; y_max = {} }}", world.x, world.y);