Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
example
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SMAC
AMAK
Python
PyAMAK
example
Commits
12c414c3
Commit
12c414c3
authored
4 years ago
by
Jdrezen
Browse files
Options
Downloads
Patches
Plain Diff
Ajout d'un graphique dans la simulation des fourmis
parent
3caef389
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ant_example/controleurAntsExample.py
+10
-0
10 additions, 0 deletions
ant_example/controleurAntsExample.py
philosopher_example/philosophersAmasExample.py
+28
-28
28 additions, 28 deletions
philosopher_example/philosophersAmasExample.py
with
38 additions
and
28 deletions
ant_example/controleurAntsExample.py
+
10
−
0
View file @
12c414c3
...
...
@@ -8,9 +8,17 @@ class ControleurAntsExample(Controleur):
super
().
__init__
(
fenetre
,
amas
)
self
.
__ants
=
[]
self
.
__numberAnts
=
nbr_ants
self
.
__chart
=
[]
self
.
__chart
.
append
(
self
.
addPlotChart
(
'
Ants Position
'
))
def
initialisation
(
self
):
self
.
setTitle
(
self
.
__chart
[
0
],
'
Ants Position
'
)
self
.
setXLabel
(
self
.
__chart
[
0
],
'
x
'
)
self
.
setYLabel
(
self
.
__chart
[
0
],
'
y
'
)
self
.
setPolicy
(
self
.
__chart
[
0
],
0
,
'
go
'
)
widthCanvas
=
self
.
get_fenetre
().
get_canvas_width
()
heightCanvas
=
self
.
get_fenetre
().
get_canvas_height
()
...
...
@@ -23,6 +31,8 @@ class ControleurAntsExample(Controleur):
for
i
in
range
(
len
(
ants
)):
x
=
ants
[
i
].
get_dx
()
y
=
ants
[
i
].
get_dy
()
self
.
addPoint
(
self
.
__chart
[
0
],
0
,
x
,
y
)
color
=
ants
[
i
].
get_color
()
if
color
!=
ants
[
i
].
get_old_color
():
...
...
This diff is collapsed.
Click to expand it.
philosopher_example/philosophersAmasExample.py
+
28
−
28
View file @
12c414c3
from
pyAmakCore.classes.tools.amasIHM
import
AmasIHM
from
philosophersExample
import
PhilosophersExample
from
tableExample
import
TableExample
class
PhilosophersAmasExamples
(
AmasIHM
):
def
__init__
(
self
):
super
().
__init__
(
TableExample
())
def
on_initial_agents_creation
(
self
):
ps
=
[]
for
i
in
range
(
9
):
ps
.
append
(
PhilosophersExample
(
i
,
self
,
self
.
get_environment
().
get_forks
()[
i
],
self
.
get_environment
().
get_forks
()[
i
+
1
]))
ps
.
append
(
PhilosophersExample
(
9
,
self
,
self
.
get_environment
().
get_forks
()[
9
],
self
.
get_environment
().
get_forks
()[
0
]))
for
j
in
range
(
len
(
ps
)
-
1
):
ps
[
j
+
1
].
add_neighbour
(
ps
[
j
])
ps
[
j
].
add_neighbour
(
ps
[
j
+
1
])
ps
[
0
].
add_neighbour
(
ps
[
len
(
ps
)
-
1
])
ps
[
len
(
ps
)
-
1
].
add_neighbour
(
ps
[
0
])
self
.
add_agents
(
ps
)
\ No newline at end of file
from
pyAmakCore.classes.tools.amasIHM
import
AmasIHM
from
philosophersExample
import
PhilosophersExample
from
tableExample
import
TableExample
class
PhilosophersAmasExamples
(
AmasIHM
):
def
__init__
(
self
):
super
().
__init__
(
TableExample
())
def
on_initial_agents_creation
(
self
):
ps
=
[]
for
i
in
range
(
9
):
ps
.
append
(
PhilosophersExample
(
i
,
self
,
self
.
get_environment
().
get_forks
()[
i
],
self
.
get_environment
().
get_forks
()[
i
+
1
]))
ps
.
append
(
PhilosophersExample
(
9
,
self
,
self
.
get_environment
().
get_forks
()[
9
],
self
.
get_environment
().
get_forks
()[
0
]))
for
j
in
range
(
len
(
ps
)
-
1
):
ps
[
j
+
1
].
add_neighbour
(
ps
[
j
])
ps
[
j
].
add_neighbour
(
ps
[
j
+
1
])
ps
[
0
].
add_neighbour
(
ps
[
len
(
ps
)
-
1
])
ps
[
len
(
ps
)
-
1
].
add_neighbour
(
ps
[
0
])
self
.
add_agents
(
ps
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment