Skip to content
Snippets Groups Projects
Commit b1b5be64 authored by SAHIN Melis damla's avatar SAHIN Melis damla
Browse files

classes complete

parent f8bfd13e
No related branches found
No related tags found
No related merge requests found
...@@ -42,14 +42,12 @@ public class CellularAutomatonSimulation<S extends State<S>> ...@@ -42,14 +42,12 @@ public class CellularAutomatonSimulation<S extends State<S>>
@Override @Override
public int numberOfColumns() { public int numberOfColumns() {
//TODO: à compléter return numberOfColumns();
return 0;
} }
@Override @Override
public int numberOfRows() { public int numberOfRows() {
//TODO: à compléter return numberOfRows();
return 0;
} }
/** /**
...@@ -59,7 +57,6 @@ public class CellularAutomatonSimulation<S extends State<S>> ...@@ -59,7 +57,6 @@ public class CellularAutomatonSimulation<S extends State<S>>
* @return The cell at the specified coordinate. * @return The cell at the specified coordinate.
*/ */
public Cell<S> at(Coordinate coordinate) { public Cell<S> at(Coordinate coordinate) {
//TODO: à compléter
return null; return null;
} }
......
...@@ -4,6 +4,10 @@ import matrix.Coordinate; ...@@ -4,6 +4,10 @@ import matrix.Coordinate;
import matrix.MatrixInitializer; import matrix.MatrixInitializer;
import matrix.ListMatrix; import matrix.ListMatrix;
import controller.Simulation; import controller.Simulation;
import model.automata.GameOfLifeState;
import java.util.ArrayList;
import java.util.List;
/** /**
* An initializer for a {@link ListMatrix} of states, where each state is computed based on the value * An initializer for a {@link ListMatrix} of states, where each state is computed based on the value
...@@ -13,7 +17,8 @@ import controller.Simulation; ...@@ -13,7 +17,8 @@ import controller.Simulation;
*/ */
public class NextGenerationInitializer<S extends State<S>> implements MatrixInitializer<S> { public class NextGenerationInitializer<S extends State<S>> implements MatrixInitializer<S> {
//TODO: ajouter les propriétés nécessaires CellularAutomatonSimulation<S> simulation;
/** Create a {@link MatrixInitializer} to compute the next generation in /** Create a {@link MatrixInitializer} to compute the next generation in
* a 2D cellular automaton. * a 2D cellular automaton.
...@@ -21,13 +26,17 @@ public class NextGenerationInitializer<S extends State<S>> implements MatrixInit ...@@ -21,13 +26,17 @@ public class NextGenerationInitializer<S extends State<S>> implements MatrixInit
* @param simulation the {@link Simulation} representing the cellular automaton. * @param simulation the {@link Simulation} representing the cellular automaton.
*/ */
public NextGenerationInitializer(CellularAutomatonSimulation<S> simulation) { public NextGenerationInitializer(CellularAutomatonSimulation<S> simulation) {
//TODO: à compléter this.simulation = simulation;
} }
@Override @Override
public S initialValueAt(Coordinate coordinate) { public S initialValueAt(Coordinate coordinate) {
//TODO: à compléter List<Coordinate> coordinates = coordinate.orthogonalNeighbours();
return null; List<S> states = new ArrayList<>();
for (Coordinate c : coordinates) {
states.add(simulation.at(this.wrap(c)).get());
}
return simulation.at(coordinate).get().update(states);
} }
/** Computes the grid {@link Coordinate} for an arbitrary {@link Coordinate}, even outside /** Computes the grid {@link Coordinate} for an arbitrary {@link Coordinate}, even outside
...@@ -39,10 +48,9 @@ public class NextGenerationInitializer<S extends State<S>> implements MatrixInit ...@@ -39,10 +48,9 @@ public class NextGenerationInitializer<S extends State<S>> implements MatrixInit
* @return a corresponding {@link Coordinate}, that is inside the grid. * @return a corresponding {@link Coordinate}, that is inside the grid.
*/ */
Coordinate wrap(Coordinate coordinate) { Coordinate wrap(Coordinate coordinate) {
//TODO: à compléter
//Il faut recalculer les coordonnées x et y modulo les dimensions de la grille. //Il faut recalculer les coordonnées x et y modulo les dimensions de la grille.
//Pour le modulo, utiliser la fonction ci-dessous, qui s'assure que le résultat est positif. //Pour le modulo, utiliser la fonction ci-dessous, qui s'assure que le résultat est positif.
return null; return new Coordinate(modulo(coordinate.x(), simulation.numberOfColumns()), modulo(coordinate.y(), simulation.numberOfRows()));
} }
/** The non-negative remainder of n divided by d. /** The non-negative remainder of n divided by d.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment