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
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