diff --git a/src/main.rs b/src/main.rs index 211ab08..61e9d8a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -220,19 +220,24 @@ fn main() -> Result<(), Box> { loop { let mut piouff: u32 = 0; - for mut r in robot_pool { + for r in &mut robot_pool { if robot::is_piouff(&r) { piouff += 1; } else { + hash.remove(&r.p); r.execute_instruction(); + check_map(&r, &world)?; + check_collisions(&r, &hash)?; + hash.insert(robot::Position { x: r.p.x, y: r.p.y }, r.id); } - check_map(&r, &world)?; - check_collisions(&r, &hash)?; } if piouff == robot_pool.len() as u32 { break; } } + for r in &robot_pool { + println!("Robot id: {}: Final position: ({}, {})", r.id, r.p.x, r.p.y); + } Ok(()) }