set robot on the map

This commit is contained in:
Volodymyr Patuta 2020-10-20 13:57:23 +02:00
parent 3d686c7770
commit f639fa3d63
1 changed files with 9 additions and 0 deletions

View File

@ -14,6 +14,15 @@ impl World {
fn create_map(&mut self) { fn create_map(&mut self) {
self.map = vec!['.'; (self.x * self.y) as usize]; self.map = vec!['.'; (self.x * self.y) as usize];
} }
/// Set robot on the map.
fn set_robot(&mut self, r: Robot) {
self.map[(r.p.x * r.p.y) as usize] = match r.o {
Orientation::N => '⬆',
Orientation::S => '⬇',
Orientation::E => '➡',
Orientation::W => '⬅',
}
}
} }
/// Struct to store robot position. /// Struct to store robot position.