Skip to content
Snippets Groups Projects
Commit fce9dbcc authored by Guyslain's avatar Guyslain
Browse files

Correction des soucis créés en templétant le projet

parent 39f46b80
No related branches found
No related tags found
No related merge requests found
...@@ -28,7 +28,7 @@ public class NextGenerationInitializer<S extends State<S>> implements MatrixInit ...@@ -28,7 +28,7 @@ public class NextGenerationInitializer<S extends State<S>> implements MatrixInit
@Override @Override
public S initialValueAt(Coordinate coordinate) { public S initialValueAt(Coordinate coordinate) {
List<State<S>> neighbours = new ArrayList<>(); List<S> neighbours = new ArrayList<>();
for (Coordinate neighbourCoord : coordinate.orthodiagonalNeighbours()) { for (Coordinate neighbourCoord : coordinate.orthodiagonalNeighbours()) {
Coordinate wrapped = wrap(neighbourCoord); Coordinate wrapped = wrap(neighbourCoord);
neighbours.add(this.simulation.at(wrapped).get()); neighbours.add(this.simulation.at(wrapped).get());
...@@ -45,7 +45,7 @@ public class NextGenerationInitializer<S extends State<S>> implements MatrixInit ...@@ -45,7 +45,7 @@ public class NextGenerationInitializer<S extends State<S>> implements MatrixInit
* @param coordinate a {@link Coordinate} that may be outside the grid. * @param coordinate a {@link Coordinate} that may be outside the grid.
* @return a corresponding {@link Coordinate}, that is inside the grid. * @return a corresponding {@link Coordinate}, that is inside the grid.
*/ */
private Coordinate wrap(Coordinate coordinate) { Coordinate wrap(Coordinate coordinate) {
return new Coordinate( return new Coordinate(
modulo(coordinate.x(),this.simulation.numberOfColumns()), modulo(coordinate.x(),this.simulation.numberOfColumns()),
modulo(coordinate.y(),this.simulation.numberOfRows()) modulo(coordinate.y(),this.simulation.numberOfRows())
...@@ -58,7 +58,7 @@ public class NextGenerationInitializer<S extends State<S>> implements MatrixInit ...@@ -58,7 +58,7 @@ public class NextGenerationInitializer<S extends State<S>> implements MatrixInit
* @param d a non-zero integer. * @param d a non-zero integer.
* @return the remainder of {@code n/d}, between {@code 0} and {@code n-1}. * @return the remainder of {@code n/d}, between {@code 0} and {@code n-1}.
*/ */
private static int modulo(int n, int d) { static int modulo(int n, int d) {
int result = n % d; int result = n % d;
return n < 0 ? result + d : result; return n < 0 ? result + d : result;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment