Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LO21_Pin_Noir_Boucher_Bouri_Detree
CellulutLO21
Commits
9666e1b5
Commit
9666e1b5
authored
May 22, 2021
by
Anthony Noir
Browse files
Simulation
parent
e072300b
Changes
3
Hide whitespace changes
Inline
Side-by-side
include/simulation.hpp
0 → 100644
View file @
9666e1b5
/**
\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
src/simulation.cpp
0 → 100644
View file @
9666e1b5
#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
;
}
src/src.pro
View file @
9666e1b5
...
...
@@ -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
\
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment