Skip to content
Snippets Groups Projects
Commit 4144bf0a authored by Jdrezen's avatar Jdrezen
Browse files

Merge branch 'master' into window_closing

parent dcedd228
No related branches found
No related tags found
No related merge requests found
...@@ -11,8 +11,11 @@ class ControleurPhilosophersExample(Controleur): ...@@ -11,8 +11,11 @@ class ControleurPhilosophersExample(Controleur):
self.__numberPhilosopher = 10 self.__numberPhilosopher = 10
self.__barChart = [] self.__barChart = []
self.__barChart.append(self.addBarChart('Eaten Pastas')) self.__barChart.append(self.addBarChart('Eaten Pastas'))
self.__barChart.append(self.addBarChart('Hours of tkinking')) self.__barChart.append(self.addPlotChart('Hours of tkinking'))
self.__barChart.append(self.addBarChart('Hours of hunger')) self.setPolicy(self.__barChart[1],0,"ro")
self.__barChart.append(self.addPlotChart('Hours of hunger'))
self.addCurve(self.__barChart[2],'g+-')
def initialisation(self): def initialisation(self):
...@@ -33,6 +36,14 @@ class ControleurPhilosophersExample(Controleur): ...@@ -33,6 +36,14 @@ class ControleurPhilosophersExample(Controleur):
self.setXLabel(self.__barChart[2],'Philosophers') self.setXLabel(self.__barChart[2],'Philosophers')
self.setYLabel(self.__barChart[2],'Hours') self.setYLabel(self.__barChart[2],'Hours')
self.draw_text(40,15, "EATING")
self.draw_text(40,45, "THINKING")
self.draw_text(40,75, "HUNGRY")
self.draw_rectangle(10, 10, 20, 20, 'green')
self.draw_rectangle(10, 40, 20, 20, 'blue')
self.draw_rectangle(10, 70, 20, 20, 'red')
for i in range(self.__numberPhilosopher): for i in range(self.__numberPhilosopher):
x = 100 * cos(2 * pi * i / self.__numberPhilosopher) + (widthCanvas / 2) x = 100 * cos(2 * pi * i / self.__numberPhilosopher) + (widthCanvas / 2)
y = 100 * sin(2 * pi * i / self.__numberPhilosopher) + (heightCanvas / 2) y = 100 * sin(2 * pi * i / self.__numberPhilosopher) + (heightCanvas / 2)
...@@ -43,9 +54,11 @@ class ControleurPhilosophersExample(Controleur): ...@@ -43,9 +54,11 @@ class ControleurPhilosophersExample(Controleur):
self.__philosophers.append(carre) self.__philosophers.append(carre)
nom = 'Mr ' + str(i) nom = 'Mr ' + str(i)
self.addColumn(self.__barChart[0],nom) self.addColumn(self.__barChart[0],nom)
self.addColumn(self.__barChart[1],nom) self.addPoint(self.__barChart[1],0,x-10,y-10)
self.addColumn(self.__barChart[2],nom) self.addPoint(self.__barChart[2],0,i*50,y)
self.addPoint(self.__barChart[2],1,i*50,y-50)
def updateWindow(self, env, amas): def updateWindow(self, env, amas):
agents = amas.get_Agents_Sorted() agents = amas.get_Agents_Sorted()
...@@ -58,11 +71,9 @@ class ControleurPhilosophersExample(Controleur): ...@@ -58,11 +71,9 @@ class ControleurPhilosophersExample(Controleur):
elif state == State.HUNGRY: elif state == State.HUNGRY:
self.change_color(self.__philosophers[i], 'red') self.change_color(self.__philosophers[i], 'red')
self.increaseValue(self.__barChart[2],i, 1)
else: else:
self.change_color(self.__philosophers[i], 'blue') self.change_color(self.__philosophers[i], 'blue')
self.increaseValue(self.__barChart[1],i, 1)
coords = self.get_coords_element(self.__philosophers[i]) coords = self.get_coords_element(self.__philosophers[i])
if agents[i].get_Left_Fork().owned(agents[i]): if agents[i].get_Left_Fork().owned(agents[i]):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment