From ae4e10f00eab3c9a7a9f5239392e67ef3c39fb1a Mon Sep 17 00:00:00 2001 From: Tom Barrett Date: Fri, 24 Nov 2017 03:42:02 -0600 Subject: -made all character variables private -moved path calculation to list level -moved needs_path to a function --- src/location.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/location.rs') diff --git a/src/location.rs b/src/location.rs index ca40700..a6ac623 100644 --- a/src/location.rs +++ b/src/location.rs @@ -5,6 +5,7 @@ impl Location { pub fn distance(&self, other: &Location) -> usize { (((self.0 - other.0).pow(2) + (self.1 - other.1).pow(2)) as f64).sqrt() as usize } + pub fn neighbours(self, impassable : Vec<(Location, usize)>) -> Vec<(Location, usize)> { let mut nearby = vec![Location(self.0 + 1, self.1), Location(self.0 - 1, self.1), Location(self.0, self.1 + 1), Location(self.0, self.1 - 1), -- cgit v1.2.3