def __init__(self, width, height, color, grid): Animat.__init__(self, width, height, color, grid) self.ai = qlearn.QLearn(actions=range(Actions.directions), alpha=0.1, gamma=0.9, epsilon=0.1) Predator.dictionaryOfPredators[(self.gridX, self.gridY)] = self
def move(self, directionX, directionY): oldXPosition = self.gridX oldYPosition = self.gridY nextXPosition = self.gridX + directionX nextYPosition = self.gridY + directionY if (self.isMovementPossible(nextXPosition, nextYPosition)): #If prey is in new position if (not Predator.dictionaryOfPredators.has_key( (nextXPosition, nextYPosition))): #Another PreyAdult is not on the next Position, so valid movement Animat.move(self, directionX, directionY) Predator.dictionaryOfPredators.pop( (oldXPosition, oldYPosition)) Predator.dictionaryOfPredators[(self.gridX, self.gridY)] = self
def __init__(self,width,height,color,grid): Animat.__init__(self, width, height, color, grid) self.ai = qlearn.QLearn(actions=range(Actions.directions),alpha=0.1, gamma=0.9, epsilon=0.1) self.eaten = 0 Prey.dictionaryOfPreys[(self.gridX,self.gridY)] = self
def move(self, directionX, directionY): #Override for subclass Animat.move(self, directionX, directionY)