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
No related branches found
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>> ...@@ -42,14 +42,12 @@ public class CellularAutomatonSimulation<S extends State<S>>
@Override @Override
public int numberOfColumns() { public int numberOfColumns() {
//TODO: à compléter return this.automaton.numberOfColumns();
return 0;
} }
@Override @Override
public int numberOfRows() { public int numberOfRows() {
//TODO: à compléter return this.automaton.numberOfRows();
return 0;
} }
/** /**
...@@ -59,13 +57,18 @@ public class CellularAutomatonSimulation<S extends State<S>> ...@@ -59,13 +57,18 @@ 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 this.grid.get(coordinate);
return null;
} }
@Override @Override
public void updateToNextGeneration() { 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 /** Computes the {@link ListMatrix} of states obtained after a single step of updates
...@@ -74,23 +77,25 @@ public class CellularAutomatonSimulation<S extends State<S>> ...@@ -74,23 +77,25 @@ public class CellularAutomatonSimulation<S extends State<S>>
* @return the states of each cell after one generation * @return the states of each cell after one generation
*/ */
private ListMatrix<S> nextGenerationMatrix() { private ListMatrix<S> nextGenerationMatrix() {
//TODO: à compléter return new ListMatrix<>(
return null; this.numberOfColumns(),this.numberOfRows(),new NextGenerationInitializer<>(this));
} }
@Override @Override
public void next(Coordinate coordinate) { public void next(Coordinate coordinate) {
//TODO: à compléter Cell <S> cell =this.at(coordinate);
S next = cell.get().next();
cell.set(next);
} }
@Override @Override
public void copy(Coordinate source, Coordinate destination) { public void copy(Coordinate source, Coordinate destination) {
//TODO: à compléter S value =this.at(source).get();
this.at(destination).set(value);
} }
@Override @Override
public Color getColor(Coordinate coordinate) { public Color getColor(Coordinate coordinate) {
//TODO: à compléter return this.at(coordinate).get().getColor();
return null;
} }
@Override @Override
...@@ -108,17 +113,31 @@ public class CellularAutomatonSimulation<S extends State<S>> ...@@ -108,17 +113,31 @@ public class CellularAutomatonSimulation<S extends State<S>>
@Override @Override
public void clear() { 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 @Override
public void reset() { 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 @Override
public Iterator<Coordinate> iterator() { public Iterator<Coordinate> iterator() {
return this.grid.coordinates().iterator(); return this.grid.coordinates().iterator();
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment