Skip to content
Snippets Groups Projects
Commit f3125304 authored by shinedday's avatar shinedday
Browse files

Merge branch 'master' of https://gitlab.com/be-pyamak/example

parents 0e3dd7f1 01d257fb
Branches
No related tags found
No related merge requests found
...@@ -11,13 +11,12 @@ class ControleurPhilosophersExample(Controleur): ...@@ -11,13 +11,12 @@ class ControleurPhilosophersExample(Controleur):
self.__left = [] self.__left = []
self.__right = [] self.__right = []
self.__numberPhilosopher = 10 self.__numberPhilosopher = 10
self.__barChart = [] self.__chart = []
self.__barChart.append(self.addBarChart('Eaten Pastas')) self.__chart.append(self.addBarChart('Eaten Pastas'))
self.__barChart.append(self.addPlotChart('Hours of tkinking')) self.__chart.append(self.addPlotChart('Hours of tkinking'))
self.setPolicy(self.__barChart[1],0,"ro") self.__chart.append(self.addLimitedPlotChart('Hours of tkinking (limited)',5))
self.__barChart.append(self.addPlotChart('Hours of hunger')) self.__hoursThinkingMr5 = 0
self.addCurve(self.__barChart[2],'g+-')
def initialisation(self): def initialisation(self):
...@@ -26,17 +25,17 @@ class ControleurPhilosophersExample(Controleur): ...@@ -26,17 +25,17 @@ class ControleurPhilosophersExample(Controleur):
# Init # Init
self.setTitle(self.__barChart[0],'Eaten Pastas') self.setTitle(self.__chart[0],'Eaten Pastas')
self.setXLabel(self.__barChart[0],'Philosophers') self.setXLabel(self.__chart[0],'Philosophers')
self.setYLabel(self.__barChart[0],'Number of eaten pastas') self.setYLabel(self.__chart[0],'Number of eaten pastas')
self.setTitle(self.__barChart[1],'Hours of thinking') self.setTitle(self.__chart[1],'Hours of thinking for Mr 4')
self.setXLabel(self.__barChart[1],'Philosophers') self.setXLabel(self.__chart[1],'Cycle')
self.setYLabel(self.__barChart[1],'Hours') self.setYLabel(self.__chart[1],'Hours')
self.setTitle(self.__barChart[2],'Hours of hunger') self.setTitle(self.__chart[2],'Hours of thinking for Mr 4 (limited)')
self.setXLabel(self.__barChart[2],'Philosophers') self.setXLabel(self.__chart[2],'Cycle')
self.setYLabel(self.__barChart[2],'Hours') self.setYLabel(self.__chart[2],'Hours')
self.draw_text(40,15, "EATING") self.draw_text(40,15, "EATING")
self.draw_text(40,45, "THINKING") self.draw_text(40,45, "THINKING")
...@@ -60,25 +59,26 @@ class ControleurPhilosophersExample(Controleur): ...@@ -60,25 +59,26 @@ class ControleurPhilosophersExample(Controleur):
nom = 'Mr ' + str(i) nom = 'Mr ' + str(i)
self.addColumn(self.__barChart[0],nom) self.addColumn(self.__chart[0],nom)
def updateWindow(self, env, amas): def updateWindow(self, env, amas):
agents = amas.get_Agents_Sorted() agents = amas.get_Agents_Sorted()
self.addPoint(self.__barChart[1],0,amas.get_cycle(),randint(0,100)) self.addPoint(self.__chart[1],0,amas.get_cycle(),self.__hoursThinkingMr5)
self.addPoint(self.__barChart[2],0,amas.get_cycle(),randint(0,100)) self.addPoint(self.__chart[2],0,amas.get_cycle(),self.__hoursThinkingMr5)
self.addPoint(self.__barChart[2],1,amas.get_cycle(),randint(0,100))
for i in range(10): for i in range(10):
state = agents[i].get_state() state = agents[i].get_state()
if state == State.EATING: if state == State.EATING:
self.change_color(self.__philosophers[i], 'green') self.change_color(self.__philosophers[i], 'green')
self.increaseValue(self.__barChart[0],i, 1) self.increaseValue(self.__chart[0],i, 1)
elif state == State.HUNGRY: elif state == State.HUNGRY:
self.change_color(self.__philosophers[i], 'red') self.change_color(self.__philosophers[i], 'red')
else: else:
self.change_color(self.__philosophers[i], 'blue') self.change_color(self.__philosophers[i], 'blue')
if(i == 5):
self.__hoursThinkingMr5 += 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