diff --git a/src/main.rs b/src/main.rs index 15ad453..e8f06c0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -198,6 +198,7 @@ fn open_file(filename: &str) -> io::Result { Ok(content) } +///Here we display the grid by looping in every position checking if it exists in the HashMap. fn display_grid( w: &world::World, robot_pool: &Vec, @@ -208,21 +209,22 @@ fn display_grid( for j in 0..w.x { match h.get(&robot::Position { x: j, y: i }) { Some(id) => match robot_pool[(id - 1) as usize].o { - robot::Orientation::N => print!("↑"), - robot::Orientation::E => print!("→"), - robot::Orientation::S => print!("↓"), - robot::Orientation::W => print!("←"), + robot::Orientation::N => print!("↑ "), + robot::Orientation::E => print!("→ "), + robot::Orientation::S => print!("↓ "), + robot::Orientation::W => print!("← "), }, - None => print!("."), + None => print!(". "), } } println!(); } - print!(" "); + print!(" "); for j in 0..w.x { print!("{} ", j); } + println!(); } fn main() -> Result<(), Box> { // We handle CLI flags here. @@ -244,7 +246,7 @@ fn main() -> Result<(), Box> { let world: world::World = parse_config(raw_conf, &mut robot_pool)?; let mut hash: HashMap = HashMap::new(); create_hash_map(&robot_pool, &mut hash); - + display_grid(&world, &robot_pool, &hash); loop { let mut piouff: u32 = 0; for r in &mut robot_pool {