diff --git a/src/main.rs b/src/main.rs index 2b816e8..8111819 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,6 +14,7 @@ // along with this program. If not, see . use clap::{App, Arg}; +use std::collections::HashMap; use std::fs; use std::io; @@ -28,7 +29,19 @@ fn check_map(r: &robot::Robot, w: &world::World) -> Result<(), String> { Ok(()) } } - +fn check_collisions( + r: &robot::Robot, + w: &world::World, + h: HashMap<&robot::Position, &u32>, +) -> Result<(), String> { + match h.get(&r.p) { + Some(&x) => Err(format!( + "The robot id: {} collided with robot id: {} in position: ({};{}).", + &r.id, x, &r.p.x, &r.p.y + )), + None => Ok(()), + } +} /// Parse the config file, generate the world and robot pool. fn parse_config(conf: String, pool: &mut Vec) -> Result { let mut lines = conf.lines();