Newer
Older
* {@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>>
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;
automaton.numberOfColumns(),
automaton.numberOfRows(),
new ConstantCellInitializer<>(automaton.defaultState())
);
this.generator = generator;
/**
* Returns the {@link Cell} at the specified coordinate.
*
* @param coordinate The coordinate of the cell to retrieve.
* @return The cell at the specified coordinate.
*/
//TODO: à compléter, en utilisant nextGenerationMatrix()
/** Computes the {@link ListMatrix} of states obtained after a single step of updates
* of the simulation.
*
* @return the states of each cell after one generation
*/
}
@Override
public void copy(Coordinate source, Coordinate destination) {
}
@Override
public Color getColor(Coordinate coordinate) {
public void setChangeListener(Coordinate coordinate, Runnable listener) {
this.at(coordinate).addOnChangeListener(
(oldValue, newValue) -> listener.run()
@Override
public void setGenerationNumberChangeListener(OnChangeListener<Integer> listener){
this.generationNumber.addOnChangeListener(listener);
//TODO: à compléter (penser à remettre le nombre de génération à 0)
//TODO: à compléter (penser à remettre le nombre de génération à 0)