def getAction(self, state): GameState.getAndResetExplored() studentAction = (self.studentAgent.getAction(state), len(GameState.getAndResetExplored())) print studentAction optimalActions = self.optimalActions[self.stepCount] altDepthActions = self.altDepthActions[self.stepCount] partialPlyBugActions = self.partialPlyBugActions[self.stepCount] studentOptimalAction = False curRightStatesExplored = False; for i in range(len(optimalActions)): if studentAction[0] in optimalActions[i][0]: studentOptimalAction = True else: self.actionsConsistentWithOptimal[i] = False if studentAction[1] == int(optimalActions[i][1]): curRightStatesExplored = True if not curRightStatesExplored and self.wrongStatesExplored < 0: self.wrongStatesExplored = 1 for i in range(len(altDepthActions)): if studentAction[0] not in altDepthActions[i]: self.actionsConsistentWithAlternativeDepth[i] = False for i in range(len(partialPlyBugActions)): if studentAction[0] not in partialPlyBugActions[i]: self.actionsConsistentWithPartialPlyBug[i] = False if not studentOptimalAction: self.suboptimalMoves.append((state, studentAction[0], optimalActions[0][0][0])) self.stepCount += 1 random.seed(self.seed + self.stepCount) return optimalActions[0][0][0]
def getAction(self, state): GameState.getAndResetExplored() studentAction = (self.studentAgent.getAction(state), sum(map(hash, GameState.getAndResetExplored()))) optimalActions = self.optimalActions[self.stepCount] altDepthActions = self.altDepthActions[self.stepCount] partialPlyBugActions = self.partialPlyBugActions[self.stepCount] studentOptimalAction = False curRightStatesExplored = False; for i in range(len(optimalActions)): if studentAction[0] in optimalActions[i][0]: studentOptimalAction = True else: self.actionsConsistentWithOptimal[i] = False if studentAction[1] == int(optimalActions[i][1]): curRightStatesExplored = True if not curRightStatesExplored and self.wrongStatesExplored < 0: self.wrongStatesExplored = 1 for i in range(len(altDepthActions)): if studentAction[0] not in altDepthActions[i]: self.actionsConsistentWithAlternativeDepth[i] = False for i in range(len(partialPlyBugActions)): if studentAction[0] not in partialPlyBugActions[i]: self.actionsConsistentWithPartialPlyBug[i] = False if not studentOptimalAction: self.suboptimalMoves.append((state, studentAction[0], optimalActions[0][0][0])) self.stepCount += 1 random.seed(self.seed + self.stepCount) return optimalActions[0][0][0]
def getAction(self, state): # survey agents GameState.getAndResetExplored() optimalActionLists = [] for agent in self.solutionAgents: optimalActionLists.append( ( agent.getBestPacmanActions(state)[0], len(GameState.getAndResetExplored()), ) ) alternativeDepthLists = [ agent.getBestPacmanActions(state)[0] for agent in self.alternativeDepthAgents ] partialPlyBugLists = [ agent.getBestPacmanActions(state)[0] for agent in self.partialPlyBugAgents ] # record responses self.optimalActionLists.append(optimalActionLists) self.alternativeDepthLists.append(alternativeDepthLists) self.partialPlyBugLists.append(partialPlyBugLists) self.stepCount += 1 random.seed(self.seed + self.stepCount) return optimalActionLists[0][0][0]
def processGames(self): maxNumTraining = DatatypeUtils.stringToInteger(self.view.numTrainingVar.get()) increment = DatatypeUtils.stringToInteger(self.view.incrementVar.get()) #from pympler import tracker #memory_tracker = tracker.SummaryTracker() for numTraining in range(0, maxNumTraining, increment): self.processGame(numTraining) GameState.getAndResetExplored()
def getAction(self, state): # survey agents GameState.getAndResetExplored() optimalActionLists = [] for agent in self.solutionAgents: optimalActionLists.append((agent.getBestPacmanActions(state)[0], sum(map(hash, GameState.getAndResetExplored())))) alternativeDepthLists = [agent.getBestPacmanActions(state)[0] for agent in self.alternativeDepthAgents] partialPlyBugLists = [agent.getBestPacmanActions(state)[0] for agent in self.partialPlyBugAgents] # record responses self.optimalActionLists.append(optimalActionLists) self.alternativeDepthLists.append(alternativeDepthLists) self.partialPlyBugLists.append(partialPlyBugLists) self.stepCount += 1 random.seed(self.seed + self.stepCount) return optimalActionLists[0][0][0]
def getAction(self, state): GameState.getAndResetExplored() studentAction = (self.studentAgent.getAction(state), len(GameState.getAndResetExplored())) optimalActions = self.optimalActions[self.stepCount] studentOptimalAction = False curRightStatesExplored = False for i in range(len(optimalActions)): if studentAction[0] in optimalActions[i][0]: studentOptimalAction = True else: self.actionsConsistentWithOptimal[i] = False if studentAction[1] == int(optimalActions[i][1]): curRightStatesExplored = True if not curRightStatesExplored and self.wrongStatesExplored < 0: self.wrongStatesExplored = 1 if not studentOptimalAction: self.suboptimalMoves.append( (state, studentAction[0], optimalActions[0][0][0])) self.stepCount += 1 random.seed(self.seed + self.stepCount) return optimalActions[0][0][0]