Select Git revision
CellularAutomatonSimulation.java
Forked from
YAGOUBI Rim / Game of life Template
Source project has a limited visibility.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
CellularAutomatonSimulation.java 3.23 KiB
package model;
import controller.Simulation;
import datastruct.Coordinate;
import datastruct.Matrix;
import javafx.scene.paint.Color;
import java.util.Iterator;
import java.util.Random;
/**
* {@link CellularAutomatonSimulation} instances run <i>The Game of Life</i>.
*
* @param <S> The type of state used in the simulation.
*/
public class CellularAutomatonSimulation<S extends State<S>>
implements Simulation {
private final Matrix<Cell<S>> grid;
private final Cell<Integer> generationNumber = new Cell<>(0);
private final CellularAutomaton<S> automaton;
private final Random generator;
/**
* Creates a new {@link CellularAutomatonSimulation} instance for a given automaton.
*
* @param automaton A description of the {@link CellularAutomaton}.
* @param generator The {@link Random} instance used for random state generation.
*/
public CellularAutomatonSimulation(CellularAutomaton<S> automaton, Random generator) {
this.automaton = automaton;
this.grid = new Matrix<>(
automaton.numberOfColumns(),
automaton.numberOfRows(),
new ConstantCellInitializer<>(automaton.defaultState())
);
this.generator = generator;
}
@Override
public int numberOfColumns() {
//TODO: à compléter
return 0;
}
@Override
public int numberOfRows() {
//TODO: à compléter
return 0;
}
/**
* Returns the {@link Cell} at the specified coordinate.
*
* @param coordinate The coordinate of the cell to retrieve.
* @return The cell at the specified coordinate.
*/
public Cell<S> at(Coordinate coordinate) {
//TODO: à compléter
return null;
}
@Override
public void updateToNextGeneration() {
//TODO: à compléter, en utilisant nextGenerationMatrix()
}