Skip to content
Snippets Groups Projects
Commit 42c0645a authored by hiba1907's avatar hiba1907
Browse files

Realisation des derinieres taches du ttp jeu de la vie

parent c695e6fc
Branches main
No related tags found
No related merge requests found
Pipeline #41726 passed
Showing
with 40 additions and 18 deletions
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
{
"java.debug.settings.onBuildFailureProceed": true
}
\ No newline at end of file
No preview for this file type
No preview for this file type
No preview for this file type
File deleted
No preview for this file type
No preview for this file type
......@@ -42,14 +42,12 @@ public class CellularAutomatonSimulation<S extends State<S>>
@Override
public int numberOfColumns() {
//TODO: à compléter
return 0;
return this.automaton.numberOfColumns();
}
@Override
public int numberOfRows() {
//TODO: à compléter
return 0;
return this.automaton.numberOfRows();
}
/**
......@@ -59,14 +57,19 @@ public class CellularAutomatonSimulation<S extends State<S>>
* @return The cell at the specified coordinate.
*/
public Cell<S> at(Coordinate coordinate) {
//TODO: à compléter
return null;
return this.grid.get(coordinate);
}
@Override
public void updateToNextGeneration() {
//TODO: à compléter, en utilisant nextGenerationMatrix()
}
ListMatrix<S> nextGeneration= nextGenerationMatrix();
for(Coordinate coordinate: this.grid.coordinates()){
S next= nextGeneration.get(coordinate);
Cell<S> cell = this.grid.get(coordinate);
cell.set(next);
}
this.generationNumber.set(this.generationNumber.get()+1);
}
/** Computes the {@link ListMatrix} of states obtained after a single step of updates
* of the simulation.
......@@ -74,23 +77,25 @@ public class CellularAutomatonSimulation<S extends State<S>>
* @return the states of each cell after one generation
*/
private ListMatrix<S> nextGenerationMatrix() {
//TODO: à compléter
return null;
return new ListMatrix<>(
this.numberOfColumns(),this.numberOfRows(),new NextGenerationInitializer<>(this));
}
@Override
public void next(Coordinate coordinate) {
//TODO: à compléter
Cell <S> cell =this.at(coordinate);
S next = cell.get().next();
cell.set(next);
}
@Override
public void copy(Coordinate source, Coordinate destination) {
//TODO: à compléter
S value =this.at(source).get();
this.at(destination).set(value);
}
@Override
public Color getColor(Coordinate coordinate) {
//TODO: à compléter
return null;
return this.at(coordinate).get().getColor();
}
@Override
......@@ -108,17 +113,31 @@ public class CellularAutomatonSimulation<S extends State<S>>
@Override
public void clear() {
//TODO: à compléter (penser à remettre le nombre de génération à 0)
}
for(Coordinate coordinate : this.grid.coordinates()){
this.at(coordinate).set(this.automaton.defaultState());
}
this.generationNumber.set(0);
}
@Override
public void reset() {
//TODO: à compléter (penser à remettre le nombre de génération à 0)
}
for(Coordinate coordinate:this.grid.coordinates()){
this.at(coordinate).set(this.automaton.randomState(this.generator));
}
this.generationNumber.set(0);
}
@Override
public Iterator<Coordinate> iterator() {
return this.grid.coordinates().iterator();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment