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 {
|
loop {
|
||||||
let mut piouff: u32 = 0;
|
let mut piouff: u32 = 0;
|
||||||
for mut r in robot_pool {
|
for r in &mut robot_pool {
|
||||||
if robot::is_piouff(&r) {
|
if robot::is_piouff(&r) {
|
||||||
piouff += 1;
|
piouff += 1;
|
||||||
} else {
|
} else {
|
||||||
|
hash.remove(&r.p);
|
||||||
r.execute_instruction();
|
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 {
|
if piouff == robot_pool.len() as u32 {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for r in &robot_pool {
|
||||||
|
println!("Robot id: {}: Final position: ({}, {})", r.id, r.p.x, r.p.y);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user