added doc and minor changes to have a better grid

This commit is contained in:
EliasCubz 2020-11-01 16:21:27 +01:00
parent 7b3bdbfa11
commit e884ff6e9b
1 changed files with 9 additions and 7 deletions

View File

@ -198,6 +198,7 @@ fn open_file(filename: &str) -> io::Result<String> {
Ok(content) Ok(content)
} }
///Here we display the grid by looping in every position checking if it exists in the HashMap.
fn display_grid( fn display_grid(
w: &world::World, w: &world::World,
robot_pool: &Vec<robot::Robot>, robot_pool: &Vec<robot::Robot>,
@ -223,6 +224,7 @@ fn display_grid(
for j in 0..w.x { for j in 0..w.x {
print!("{} ", j); print!("{} ", j);
} }
println!();
} }
fn main() -> Result<(), Box<dyn std::error::Error>> { fn main() -> Result<(), Box<dyn std::error::Error>> {
// We handle CLI flags here. // We handle CLI flags here.
@ -244,7 +246,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let world: world::World = parse_config(raw_conf, &mut robot_pool)?; let world: world::World = parse_config(raw_conf, &mut robot_pool)?;
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);
display_grid(&world, &robot_pool, &hash);
loop { loop {
let mut piouff: u32 = 0; let mut piouff: u32 = 0;
for r in &mut robot_pool { for r in &mut robot_pool {