Use neighbours method in predator and prey.
This commit is contained in:
parent
6009f627ae
commit
3761bcfccf
@ -71,8 +71,7 @@ fn send<T: Write>(w: &mut T, board: &Board) -> std::io::Result<()> {
|
||||
const DEFAULT_ARG: usize = 10;
|
||||
|
||||
fn grow(board: &Board, pos: Point2d, grow: Square, die: Square) -> Square {
|
||||
for dir in Vec2d::directions() {
|
||||
let pos1 = pos + dir;
|
||||
for pos1 in pos.neighbours() {
|
||||
if board.rect().contains(pos1) {
|
||||
let neigh_sq = board.get(pos1);
|
||||
if neigh_sq == grow {
|
||||
|
Loading…
Reference in New Issue
Block a user