def update(self, model): Pulsator.update(self, model) nearbyPrey = model.find(lambda x: isinstance(x, Prey) and self. distance((x.get_location())) <= 200) toSort = [] for prey in nearbyPrey: toSort.append((prey, self.distance((prey.get_location())))) if toSort != []: prey_to_chase = min(toSort, key=lambda x: x[1]) xp, yp = Prey.get_location(prey_to_chase[0]) xh, yh = self.get_location() diff_y = yp - yh diff_x = xp - xh self.set_angle(atan2(diff_y, diff_x)) Mobile_Simulton.move(self)