Skip to content
GitLab
Menu
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
12c9e357
Commit
12c9e357
authored
Jun 05, 2021
by
Anthony Noir
Browse files
Gestion période
parent
3a2516b1
Pipeline
#79251
canceled with stage
Changes
5
Pipelines
1
Show whitespace changes
Inline
Side-by-side
include/grid.h
View file @
12c9e357
...
...
@@ -66,6 +66,7 @@ public:
+
((
j
%
nb_col
+
nb_col
)
%
nb_col
)];
}
Grid
&
operator
=
(
const
Grid
&
g
);
bool
operator
==
(
const
Grid
&
);
//! \brief Retourne une structure représentant le contenu non-nul de la Grid (les cellules d'état != 0), pour un enregistrement dans un fichier par exemple.
Structure
to_structure
()
const
;
...
...
include/simulation.hpp
View file @
12c9e357
...
...
@@ -16,7 +16,8 @@ Cette classe représente un automate cellulaire dans le temps.
class
Simulation
{
private:
bool
canRun
;
int
time
;
unsigned
int
time
;
unsigned
int
period
;
Automaton
automaton
;
Grid
startGrid
;
History
hist
;
...
...
@@ -78,6 +79,15 @@ public:
//! \return vrai si la simulation peut tourner
bool
runnable
()
{
return
canRun
;}
//! \brief Donne la période de la simulation
//!
//! Si elle n'est pas encore obtenue : vaut 0
//! \return période de la simulation
unsigned
int
getPeriod
()
{
return
period
;}
//! \brief Indique l'étape actuelle de la simulation
//! \return nombre de pas depuis le début
unsigned
int
getTime
()
{
return
time
;}
//! \brief Remet la simulation dans son état de départ
...
...
src/grid.cpp
View file @
12c9e357
...
...
@@ -47,6 +47,10 @@ Grid& Grid::operator=(const Grid& g){
return
*
this
;
}
bool
Grid
::
operator
==
(
const
Grid
&
G
)
{
return
nb_rows
==
G
.
nb_rows
&&
nb_col
==
G
.
nb_col
&&
matrix
==
G
.
matrix
;
}
Structure
Grid
::
to_structure
()
const
{
std
::
vector
<
std
::
pair
<
Coord
,
unsigned
>>
data
;
...
...
src/interface.cpp
View file @
12c9e357
...
...
@@ -618,6 +618,7 @@ void MainWindow::on_nextButton_clicked()
simulation
.
setGrid
(
ui
->
grid_view
->
get_grid
());
simulation
.
step
();
ui
->
grid_view
->
copy_grid
(
simulation
.
getGrid
());
ui
->
stepsPeriodLabel
->
setText
(
QString
::
number
(
simulation
.
getPeriod
())
+
" steps"
);
}
void
MainWindow
::
on_prevButton_clicked
()
...
...
@@ -653,6 +654,7 @@ void MainWindow::on_resetButton_clicked() {
}
simulation
.
reset
();
ui
->
grid_view
->
copy_grid
(
simulation
.
getGrid
());
ui
->
stepsPeriodLabel
->
setText
(
QString
::
number
(
simulation
.
getPeriod
())
+
" steps"
);
}
void
MainWindow
::
on_recordSpinBox_valueChanged
(
int
newSize
)
{
...
...
src/simulation.cpp
View file @
12c9e357
#include
"simulation.hpp"
Simulation
::
Simulation
()
:
canRun
(
false
),
time
(
0
),
automaton
(),
startGrid
(
0
,
0
),
hist
(
10
)
{}
Simulation
::
Simulation
()
:
canRun
(
false
),
time
(
0
),
period
(
0
),
automaton
(),
startGrid
(
0
,
0
),
hist
(
10
)
{}
Simulation
::~
Simulation
()
{}
...
...
@@ -61,7 +61,8 @@ void Simulation::resize(size_t l,size_t c) {
void
Simulation
::
reset
()
{
automaton
.
setGrid
(
startGrid
);
time
=
0
;
hist
=
History
(
10
);
period
=
0
;
hist
=
History
(
hist
.
get_nbMax
());
}
void
Simulation
::
step
()
{
...
...
@@ -69,6 +70,9 @@ void Simulation::step() {
automaton
.
runOnce
();
automaton
.
getNeighborhoodRule
()
->
step
();
++
time
;
if
(
!
period
&&
startGrid
==
automaton
.
getGrid
())
{
period
=
time
;
}
}
bool
Simulation
::
back
()
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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