working main-loop
This commit is contained in:
parent
a470e883af
commit
60a721742a
11
src/main.rs
11
src/main.rs
@ -220,19 +220,24 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
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(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user