Commit 9666e1b5 authored by Anthony Noir's avatar Anthony Noir
Browse files

Simulation

parent e072300b
/**
\file simulation.hpp
\brief Simulation
Cette classe représente un automate cellulaire dans le temps.
**/
#ifndef SIMULATION_HPP
#define SIMULATION_HPP
#include "history.h"
#include "grid.h"
#include "automaton.hpp"
class Simulation {
private:
int time;
Automaton automaton;
Grid startGrid;
History hist;
public:
Simulation();
virtual ~Simulation();
void setAutomaton(const Automaton&);
void reset();
void step();
void back();
};
#endif // SIMULATION_HPP
#include "simulation.hpp"
Simulation::Simulation() : automaton(nullptr, nullptr), hist(10), startGrid(0,0), time(0)
{
//ctor
}
Simulation::~Simulation()
{
//dtor
}
void Simulation::setAutomaton(const Automaton& A) {
automaton = A;
startGrid = automaton.getGrid();
time = 0;
hist = History(10);
}
void Simulation::reset() {
automaton.setGrid(startGrid);
time = 0;
hist = History(10);
}
void Simulation::step() {
hist.pushGrid(automaton.getGrid());
automaton.runOnce();
++time;
}
void Simulation::back() {
automaton.setGrid(hist.topGrid());
hist.popGrid();
--time;
}
......@@ -20,6 +20,7 @@ SOURCES += \
mooreNeighborhoodRule.cpp \
propertyvisitors.cpp \
neighborhood.cpp \
simulation.cpp \
structurereader.cpp \
interface.cpp \
grid.cpp \
......@@ -35,6 +36,7 @@ HEADERS += \
../include/neighborhoodrule.hpp \
../include/arbitraryneighborhoodrule.hpp \
../include/mooreNeighborhoodrule.hpp \
../include/simulation.hpp \
../include/vonNeumannNeighborhoodRule.hpp \
../include/property.hpp \
../include/propertyvisitors.hpp \
......
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