From bc14ee34eaf51074b22402508182730244d731b3 Mon Sep 17 00:00:00 2001 From: Jdrezen <jeremie.drezen@gmail.com> Date: Tue, 18 May 2021 13:19:28 +0200 Subject: [PATCH] =?UTF-8?q?Modification=20des=20chart=20pour=20repr=C3=A9s?= =?UTF-8?q?enter=20quelque=20chose=20de=20coh=C3=A9rent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controleurPhilosophersExample.py | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/philosopher_example/controleurPhilosophersExample.py b/philosopher_example/controleurPhilosophersExample.py index b8bdbe0..75b8c0f 100644 --- a/philosopher_example/controleurPhilosophersExample.py +++ b/philosopher_example/controleurPhilosophersExample.py @@ -11,13 +11,12 @@ class ControleurPhilosophersExample(Controleur): self.__left = [] self.__right = [] self.__numberPhilosopher = 10 - self.__barChart = [] - self.__barChart.append(self.addBarChart('Eaten Pastas')) - self.__barChart.append(self.addLimitedPlotChart('Hours of tkinking',5)) - self.setPolicy(self.__barChart[1],0,"ro") + self.__chart = [] + self.__chart.append(self.addBarChart('Eaten Pastas')) + self.__chart.append(self.addPlotChart('Hours of tkinking')) + self.__chart.append(self.addLimitedPlotChart('Hours of tkinking (limited)',5)) - self.__barChart.append(self.addLimitedPlotChart('Hours of hunger',5)) - self.addCurve(self.__barChart[2],'g+-') + self.__hoursThinkingMr5 = 0 def initialisation(self): @@ -26,17 +25,17 @@ class ControleurPhilosophersExample(Controleur): # Init - self.setTitle(self.__barChart[0],'Eaten Pastas') - self.setXLabel(self.__barChart[0],'Philosophers') - self.setYLabel(self.__barChart[0],'Number of eaten pastas') + self.setTitle(self.__chart[0],'Eaten Pastas') + self.setXLabel(self.__chart[0],'Philosophers') + self.setYLabel(self.__chart[0],'Number of eaten pastas') - self.setTitle(self.__barChart[1],'Hours of thinking') - self.setXLabel(self.__barChart[1],'Philosophers') - self.setYLabel(self.__barChart[1],'Hours') + self.setTitle(self.__chart[1],'Hours of thinking for Mr 4') + self.setXLabel(self.__chart[1],'Cycle') + self.setYLabel(self.__chart[1],'Hours') - self.setTitle(self.__barChart[2],'Hours of hunger') - self.setXLabel(self.__barChart[2],'Philosophers') - self.setYLabel(self.__barChart[2],'Hours') + self.setTitle(self.__chart[2],'Hours of thinking for Mr 4 (limited)') + self.setXLabel(self.__chart[2],'Cycle') + self.setYLabel(self.__chart[2],'Hours') self.draw_text(40,15, "EATING") self.draw_text(40,45, "THINKING") @@ -60,25 +59,26 @@ class ControleurPhilosophersExample(Controleur): nom = 'Mr ' + str(i) - self.addColumn(self.__barChart[0],nom) + self.addColumn(self.__chart[0],nom) def updateWindow(self, env, amas): agents = amas.get_Agents_Sorted() - self.addPoint(self.__barChart[1],0,amas.get_cycle(),randint(0,100)) - self.addPoint(self.__barChart[2],0,amas.get_cycle(),randint(0,100)) - self.addPoint(self.__barChart[2],1,amas.get_cycle(),randint(0,100)) + self.addPoint(self.__chart[1],0,amas.get_cycle(),self.__hoursThinkingMr5) + self.addPoint(self.__chart[2],0,amas.get_cycle(),self.__hoursThinkingMr5) for i in range(10): state = agents[i].get_state() if state == State.EATING: 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: self.change_color(self.__philosophers[i], 'red') else: self.change_color(self.__philosophers[i], 'blue') + if(i == 5): + self.__hoursThinkingMr5 += 1 coords = self.get_coords_element(self.__philosophers[i]) if agents[i].get_Left_Fork().owned(agents[i]): -- GitLab