function to check if robot is in the map

This commit is contained in:
EliasCubz 2020-10-29 10:05:54 +01:00
parent 4fc0f07e78
commit 2eaf624137
1 changed files with 8 additions and 6 deletions

View File

@ -20,13 +20,15 @@ use std::io;
mod robot; mod robot;
mod world; mod world;
fn check_map(r: &robot::Robot, w: &world::World) -> Result<(), &'static str> {} /// Check if the robot is in the map.
fn check_collisions( fn check_map(r: &robot::Robot, w: &world::World) -> Result<(), String> {
w: &world::World, if (r.p.x, r.p.y) < (0, 0) && (r.p.x, r.p.y) > (w.x, w.y) {
r: &robot::Robot, Err(format!("The robot {} is off map", r.id))
h: &collection::HashMap<robot::Position, u32>, } else {
) -> Result<(), &'static str> { Ok(())
} }
}
/// Parse the config file, generate the world and robot pool. /// Parse the config file, generate the world and robot pool.
fn parse_config(conf: String, pool: &mut Vec<robot::Robot>) -> Result<world::World, &'static str> { fn parse_config(conf: String, pool: &mut Vec<robot::Robot>) -> Result<world::World, &'static str> {
let mut lines = conf.lines(); let mut lines = conf.lines();