documentation

This commit is contained in:
Martin HART 2020-11-08 22:10:11 +01:00
parent 5fe6dfcb65
commit 1c47698453
2 changed files with 5 additions and 0 deletions

View File

@ -59,6 +59,7 @@ fn create_hash_map(pool: &Vec<robot::Robot>, hash: &mut HashMap<robot::Position,
} }
} }
/// Generate a new world.
fn gen_world(pool: &mut Vec<robot::Robot>) -> Result<world::World, String> { fn gen_world(pool: &mut Vec<robot::Robot>) -> Result<world::World, String> {
let w = world::random_world(); let w = world::random_world();
let mut rng = rand::thread_rng(); let mut rng = rand::thread_rng();

View File

@ -59,6 +59,7 @@ pub enum Orientation {
W, W,
} }
/// Return new Orientation with a left move apply to it.
fn turn_left(o: &Orientation) -> Orientation { fn turn_left(o: &Orientation) -> Orientation {
match o { match o {
Orientation::N => Orientation::W, Orientation::N => Orientation::W,
@ -67,6 +68,8 @@ fn turn_left(o: &Orientation) -> Orientation {
Orientation::W => Orientation::S, Orientation::W => Orientation::S,
} }
} }
/// Return new Orientation with a right move apply to it.
fn turn_right(o: &Orientation) -> Orientation { fn turn_right(o: &Orientation) -> Orientation {
match o { match o {
Orientation::N => Orientation::E, Orientation::N => Orientation::E,
@ -84,6 +87,7 @@ pub enum Instruction {
F, F,
} }
/// Convert a string of instructions to a Vec of instructions.
pub fn instructions_from_string(s: String) -> Result<Vec<Instruction>, String> { pub fn instructions_from_string(s: String) -> Result<Vec<Instruction>, String> {
let mut v: Vec<Instruction> = Vec::new(); let mut v: Vec<Instruction> = Vec::new();
for c in s.chars() { for c in s.chars() {