def getAction(self, gameState): startTime = time.time() if self.factory.args["noDying"]: try: action = CaptureAgent.getAction(self, gameState) except: print "exception caught by noDying, choosing random action" print traceback.format_exc() action = random.choice(gameState.getLegalActions(self.index)) else: action = CaptureAgent.getAction(self, gameState) endTime = time.time() # update moveHistory with this move self.moveHistory.push(action) if len(self.moveHistory.list) > 3: self.moveHistory.pop() print "Agent %d using %s returned action %s in %.3f seconds" % (self.index, self.role, action, endTime-startTime) self.factory.reportRuntime(endTime-startTime) return action