From 67c292b9e233be71236befd99e9f1665317cb928 Mon Sep 17 00:00:00 2001 From: Martin HART Date: Tue, 20 Oct 2020 16:57:51 +0200 Subject: [PATCH] Add empty_position() --- src/main.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main.rs b/src/main.rs index 3652955..dd5a77a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,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.