Merge branch 'master' into pest-rand-instr
This commit is contained in:
commit
959ca38231
12
src/main.rs
12
src/main.rs
@ -233,12 +233,22 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.help("Configuration file"),
|
.help("Configuration file"),
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("random-world")
|
||||||
|
.long("random-world")
|
||||||
|
.takes_value(false)
|
||||||
|
.help("Generate random world"),
|
||||||
|
)
|
||||||
.get_matches();
|
.get_matches();
|
||||||
|
|
||||||
let raw_conf = open_file(matches.value_of("file").unwrap_or("two_robots.txt"))?;
|
let raw_conf = open_file(matches.value_of("file").unwrap_or("two_robots.txt"))?;
|
||||||
|
|
||||||
let mut robot_pool: Vec<robot::Robot> = Vec::new();
|
let mut robot_pool: Vec<robot::Robot> = 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<robot::Position, u32> = HashMap::new();
|
let mut hash: HashMap<robot::Position, u32> = HashMap::new();
|
||||||
create_hash_map(&robot_pool, &mut hash);
|
create_hash_map(&robot_pool, &mut hash);
|
||||||
println!("World {{ x_max = {}; y_max = {} }}", world.x, world.y);
|
println!("World {{ x_max = {}; y_max = {} }}", world.x, world.y);
|
||||||
|
Loading…
Reference in New Issue
Block a user