Skip to content
Snippets Groups Projects
Commit 12c414c3 authored by Jdrezen's avatar Jdrezen
Browse files

Ajout d'un graphique dans la simulation des fourmis

parent 3caef389
No related branches found
No related tags found
No related merge requests found
......@@ -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():
......
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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment