예제 #1
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 PreyAdult.dictionaryOfPreyAdults.has_key((nextXPosition, nextYPosition)):
             # Another PreyAdult is not on the next Position, so valid movement
             Prey.move(self, directionX, directionY)
             PreyAdult.dictionaryOfPreyAdults.pop((oldXPosition, oldYPosition))
             PreyAdult.dictionaryOfPreyAdults[(self.gridX, self.gridY)] = self
예제 #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 PreyAdult.dictionaryOfPreyAdults.has_key(
             (nextXPosition, nextYPosition))):
             #Another PreyAdult is not on the next Position, so valid movement
             Prey.move(self, directionX, directionY)
             PreyAdult.dictionaryOfPreyAdults.pop(
                 (oldXPosition, oldYPosition))
             PreyAdult.dictionaryOfPreyAdults[(self.gridX,
                                               self.gridY)] = self