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
df808926
Commit
df808926
authored
May 30, 2021
by
Anthony Noir
Browse files
update simulation interface
parent
ca9d9c7e
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/simulation.hpp
View file @
df808926
...
...
@@ -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
();
...
...
src/simulation.cpp
View file @
df808926
...
...
@@ -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
();
...
...
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