diff --git a/Grid.java b/Grid.java index 19f447fff62369f99b488cab25cc0ffd201abf67..2567832e4d92dbb6764925642689508a6dbbdd32 100644 --- a/Grid.java +++ b/Grid.java @@ -107,7 +107,7 @@ public class Grid implements Iterable<Cell> { private boolean calculateNextState(int rowIndex, int columnIndex, Cell cell) { int aliveNeighbours = countAliveNeighbours(rowIndex, columnIndex); if (cell.isAlive()) { - return aliveNeighbours > 1 && aliveNeighbours < 4; + return aliveNeighbours >= 2 && aliveNeighbours <= 3; } return aliveNeighbours == 3; } @@ -127,7 +127,7 @@ public class Grid implements Iterable<Cell> { List<Cell> cells = new ArrayList<>(); for (int i = rowIndex - 1; i <= rowIndex + 1; i++) { for (int j = columnIndex - 1; j <= columnIndex + 1; j++) { - if (i != rowIndex && j != columnIndex || i > 0 && j > 0 && i < getNumberOfRows() && j < getNumberOfColumns()) + if ((!(i == rowIndex && j == columnIndex)) && i > 0 && j > 0 && i < getNumberOfRows() && j < getNumberOfColumns()) cells.add(getCell(i, j)); } } diff --git a/out/production/tp3/Grid.class b/out/production/tp3/Grid.class index 056f19902a2199cee6fdae89286ef9e11ac6a3e7..e700d5d726f22901bb94e808d42c7e2b105862f1 100644 Binary files a/out/production/tp3/Grid.class and b/out/production/tp3/Grid.class differ