def run_AI(self, school):
        "Execute the three boid rules and store in steering."
        self.steering = vector.Vector2(0, 0)
        # Follow rules of separation, alignment, and cohesion.
        separation = vector.Vector2(0, 0)
        alignment = vector.Vector2(0, 0)
        cohesion = vector.Vector2(0, 0)
        # Track fish that are too close along with neighbours.
        too_close = False
        neighbors = 0
        # Loop over all other fish from the school fish is in.
        for fish in school:
            if fish is not self:
                # Get the difference in location and distance.
                offset = self.location - fish.location
                length = offset.magnitude
                # Find fish that are too close to current one.
                if length < self.DESIRED_SEPARATION:
                    separation += offset.normalize() / length
                    too_close = True
                # Try joining fish in fish's present vicinity.
                if length < self.NEIGHBOR_DISTANCE:
                    alignment += fish.velocity
                    cohesion += fish.location
                    neighbors += 1
        # Steer away from fish in this school that are nearby.
        if too_close:
            self.steering += self.correction(separation) * self.SEP_FACTOR
        # Gather with and align to schoolmates detected above.
        if neighbors:
            self.steering += self.correction(alignment) * self.ALI_FACTOR
            cohesion /= neighbors
            cohesion -= self.location
            self.steering += self.correction(cohesion) * self.ALI_FACTOR
Execute the three boid rules and store in steering.
recipes/Python/578007_processing_DEMO_Boids/recipe-578007.py