add 83
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user