Commit df808926 authored by Anthony Noir's avatar Anthony Noir
Browse files

update simulation interface

parent ca9d9c7e
......@@ -28,9 +28,11 @@ public:
void setNeighborhoodRule(NeighborhoodRule*);
void setTransitionRule(TransitionRule*);
void setAlphabet(const Alphabet&);
const Alphabet& getAlphabet() const {return automaton.getAlphabet();}
void setGrid(const Grid&);
const Grid& getGrid() const;
void setCell(const Coord&, unsigned int);
void resize(size_t,size_t);
//void setCell(const Coord&, unsigned int);
//void resize(size_t,size_t);
void reset();
void step();
......
......@@ -27,7 +27,18 @@ const Grid& Simulation::getGrid() const {
return automaton.getGrid();
}
void Simulation::setCell(const Coord& coord, unsigned int val) {
void Simulation::setGrid(const Grid & grid) {
if(!time) {
startGrid = grid;
time = 0;
hist = History(10);
} else if((grid.get_col() != automaton.getGrid().get_col())&&(grid.get_rows() != automaton.getGrid().get_rows())) {
return;
}
automaton.setGrid(grid);
}
/*void Simulation::setCell(const Coord& coord, unsigned int val) {
automaton.setCell(coord, val);
startGrid.set_cell(coord, val);
}
......@@ -45,7 +56,7 @@ void Simulation::resize(size_t l,size_t c) {
startGrid = newGrid;
reset();
}
}*/
void Simulation::reset() {
automaton.setGrid(startGrid);
......@@ -61,7 +72,7 @@ void Simulation::step() {
}
void Simulation::back() {
if(hist.isEmpty()) {
if(!hist.isEmpty()) {
automaton.setGrid(hist.topGrid());
//automaton.getNeighborhoodRule()->back();
hist.popGrid();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment