diff --git a/Cargo.toml b/Cargo.toml index 863e846..740a020 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,3 +8,4 @@ edition = "2018" [dependencies] clap = "2.33.3" +queues = "1.1.0" diff --git a/src/main.rs b/src/main.rs index 54baa26..dd5a77a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ use clap::{App, Arg}; +use queues::*; use std::fs; use std::io; @@ -23,6 +24,10 @@ impl World { Orientation::W => '←', } } + /// Check if a position is free. + fn empty_position(&mut self, p: Position) -> bool { + self.map[(p.x * p.y) as usize] == '.' + } } /// Struct to store robot position. @@ -37,6 +42,7 @@ struct Robot { id: u32, o: Orientation, p: Position, + q: Queue, } impl Robot { @@ -68,19 +74,19 @@ impl Robot { } } /// Apply North orientation to the robot. - fn to_north(&mut self) { + fn turn_north(&mut self) { self.o = Orientation::N } /// Apply South orientation to the robot. - fn to_south(&mut self) { + fn turn_south(&mut self) { self.o = Orientation::S } /// Apply East orientation to the robot. - fn to_east(&mut self) { + fn turn_east(&mut self) { self.o = Orientation::E } /// Apply West orientation to the robot. - fn to_west(&mut self) { + fn turn_west(&mut self) { self.o = Orientation::W } }