Esempio n. 1
0
 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
Esempio n. 2
0
 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
Esempio n. 3
0
 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      
Esempio n. 4
0
 def move(self, directionX, directionY):
     #Override for subclass
     Animat.move(self, directionX, directionY)
Esempio n. 5
0
 def move(self, directionX, directionY):
     #Override for subclass
     Animat.move(self, directionX, directionY)