From 3761bcfccfb19bb38fd2b36b51d271f8fbc3a859 Mon Sep 17 00:00:00 2001 From: Juergen Stuber Date: Sat, 1 Dec 2018 14:41:19 +0100 Subject: [PATCH] Use neighbours method in predator and prey. --- src/bin/predprey/main.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/bin/predprey/main.rs b/src/bin/predprey/main.rs index 6b3f1de..4bfc9cf 100644 --- a/src/bin/predprey/main.rs +++ b/src/bin/predprey/main.rs @@ -71,8 +71,7 @@ fn send(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 {