def newEpisode(self): """ modify the original controller parameters and store the deltas """ DirectAgent.newEpisode(self) if not self.evaluation: self.deltaList.append(self.deltas.copy()) self.deltas = random.uniform(-self.epsilon, self.epsilon, len(self.controller.parameters)) self.controller.parameters = self.storedParameters + self.deltas self.epsilon *= self.decay
def __init__(self, faClass=Linear): self.deltas = None self.alpha = 0.01 self.epsilon = 0.1 self.decay = 0.99 self.deltaList = [] self._evaluation = False DirectAgent.__init__(self, faClass)
def forget(self): DirectAgent.forget(self) self.deltaList = []
def _setup(self, conditions): """ setup the agent and copy the original parameters. """ DirectAgent._setup(self, conditions) self.storedParameters = copy(self.controller.parameters) self.deltas = random.uniform(-self.epsilon, self.epsilon, len(self.controller.parameters))