This commit is contained in:
Dr. Matthias Ratajczak
2022-09-27 14:11:06 +02:00
parent f545a592bd
commit 476b55b1de
5 changed files with 139 additions and 0 deletions
+10
View File
@@ -7,6 +7,7 @@ type Coordinate = (usize, usize);
pub enum AllowedMovements {
DownRight,
DownRightUp,
DownRightUpLeft,
}
impl AllowedMovements {
@@ -14,6 +15,7 @@ impl AllowedMovements {
match self {
Self::DownRight => self.get_neighbours_down_right(c),
Self::DownRightUp => self.get_neighbours_down_right_up(c),
Self::DownRightUpLeft => self.get_neighbours_down_right_up_left(c),
}
}
@@ -28,6 +30,14 @@ impl AllowedMovements {
}
result
}
fn get_neighbours_down_right_up_left(&self, (x, y): &Coordinate) -> Vec<Coordinate> {
let mut result = self.get_neighbours_down_right_up(&(*x, *y));
if *x > 0 {
result.push((*x - 1, *y));
}
result
}
}
pub trait Matrix<T>