示例#1
0
 def run(self):
     self.render()
     self.userThread = UserThread(self.model.junior, self.model)
     self.userThread.start()
     self.iteration = 0
     while not self.isGameOver():
         self.resetTimes()
         startTime = time.time()
         self.printStats()
         
         self.otherCarUpdate()
         self.calculateError()
                     
         duration = time.time() - startTime
         timeToSleep = Const.SECONDS_PER_HEARTBEAT - duration
         # self.checkLate(timeToSleep)
         timeToSleep = max(0.01, timeToSleep)
         Display.graphicsSleep(timeToSleep)
         self.iteration += 1
     if not self.userThread.quit and not self.isLearning:
         self.outputGameResult()
     self.userThread.stop()
     Display.graphicsSleep(0.1)
     self.userThread.join()
     return self.userThread.quit