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
e072300b
Commit
e072300b
authored
May 22, 2021
by
Anthony Noir
Browse files
Automaton
parent
b7015db8
Changes
3
Hide whitespace changes
Inline
Side-by-side
include/automaton.hpp
0 → 100644
View file @
e072300b
/**
\file automaton.hpp
\brief Automaton
Cette classe représente un automate cellulaire.
**/
#ifndef AUTOMATON_HPP
#define AUTOMATON_HPP
#include
"neighborhoodrule.hpp"
#include
"transitionrule.hpp"
#include
"grid.h"
class
Automaton
{
private:
NeighborhoodRule
*
neighbourhoodRule
;
TransitionRule
*
transitionRule
;
Grid
grid
;
public:
Automaton
(
NeighborhoodRule
*
,
TransitionRule
*
,
const
Grid
&
=
Grid
(
0
,
0
));
virtual
~
Automaton
();
//! \brief Fait avancer l'automate à l'état suivant
void
runOnce
();
const
Grid
&
getGrid
()
const
{
return
grid
;}
void
setGrid
(
const
Grid
&
g
)
{
grid
=
g
;}
};
#endif // AUTOMATON_HPP
src/automaton.cpp
0 → 100644
View file @
e072300b
#include
"automaton.hpp"
Automaton
::
Automaton
(
NeighborhoodRule
*
n
,
TransitionRule
*
t
,
const
Grid
&
g
)
:
neighbourhoodRule
(
n
),
transitionRule
(
t
),
grid
(
Grid
(
g
))
{}
Automaton
::~
Automaton
()
{
delete
neighbourhoodRule
;
delete
transitionRule
;
}
void
Automaton
::
runOnce
()
{
Grid
tempGrid
(
grid
);
for
(
int
i
=
0
;
i
<
grid
.
get_rows
();
++
i
)
{
for
(
int
j
=
0
;
j
<
grid
.
get_col
();
++
j
)
{
tempGrid
.
set_cell
({
i
,
j
},
transitionRule
->
getState
(
grid
.
get_state
({
i
,
j
}),
neighbourhoodRule
->
getNeighborhood
(
grid
,
{
i
,
j
})));
}
}
neighbourhoodRule
->
step
();
for
(
int
i
=
0
;
i
<
grid
.
get_rows
();
++
i
)
{
for
(
int
j
=
0
;
j
<
grid
.
get_col
();
++
j
)
{
grid
=
tempGrid
;
}
}
}
src/src.pro
View file @
e072300b
...
...
@@ -14,6 +14,7 @@ INCLUDEPATH += ../include
SOURCES
+=
\
alphabet
.
cpp
\
arbitraryneighborhoodrule
.
cpp
\
automaton
.
cpp
\
gridview
.
cpp
\
main
.
cpp
\
mooreNeighborhoodRule
.
cpp
\
...
...
@@ -29,6 +30,7 @@ SOURCES += \
structurelibraryview
.
cpp
HEADERS
+=
\
..
/
include
/
automaton
.
hpp
\
..
/
include
/
coord
.
hpp
\
..
/
include
/
neighborhoodrule
.
hpp
\
..
/
include
/
arbitraryneighborhoodrule
.
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