Assignment 8

Concept:

Inspired by this paper I read called Steering Behaviors for Autonomous Characters, I made an interactive exploration of Steering Behaviors and how they manifest as group intelligence. The project moves beyond simple animation by giving every agent a “brain” that constantly calculates its next move based on its environment. By layering Craig Reynolds’ classic steering forces—Separation, Alignment, and Cohesion—the herd achieves a lifelike, emergent flow. When the user moves the “Lion” (mouse), the Flee steering behavior becomes the dominant force, overriding the social urge to flock. Conversely, clicking the canvas plants “Grass Patches,” which activates a Seek behavior, pulling the autonomous agents toward a new goal.

Instructions:

  • Move Mouse: Control the Lion. Watch the herd split and reform.

  • Click Canvas: Plant a Grass Patch. The herd will navigate toward it.

  • Spacebar: Clear all grass patches.

Code Highlight:

I am proud of the handleInteractions method. It creates a hierarchy of needs: Safety > Hunger > Socializing. If the predator (mouse) is close, the animal ignores the grass and the herd to save its own life.

handleInteractions(predator, foodSources) {
    let mouseDist = dist(this.pos.x, this.pos.y, predator.x, predator.y);
    
    if (mouseDist < 100) {
      // Flee from the lion
      let fleeForce = this.flee(predator).mult(5.0);
      this.applyForce(fleeForce);
      this.isPanicking = true;
    } else {
      this.isPanicking = false;
      // Seek the nearest grass
      if (foodSources.length > 0) {
        let closest = foodSources[0];
        let huntForce = this.seek(closest.pos).mult(1.5);
        this.applyForce(huntForce);
      }
    }
  }

Milestones and Challenges:

  • My first milestone was the fear state. I added a boolean isPanicking. This allows the animals to change color and increase their maxSpeed when the lion is near, which makes the flee behavior much more visible.

  • A challenge I ran into was resource management. Initially, the animals would just stay on the grass forever so I gave the grass health. As the herd grazes, the health drops until the patch disappears, forcing the herd to look for the next patch.

  • The final challenged I faced was from how the sketch looks like below. After getting all the core functionality done, the sketch still felt “unalive”. Following the feedback from my professor, I decided to add to the diversity of the sketch by making two different looking, and behaving, species: Wildebeests and Gazelles. By differentiating their steering weights, I created a “Social Anchor” group that prioritizes cohesion and a “Scout” group that favors independent wandering, making the collective movement feel like a real ecosystem.


Reflection and Future Improvements:

This project taught me that “life” in code is about the priority of forces. The biggest challenge was balancing steering behaviors so agents wouldn’t just clump like magnets. Fine tuning the Separation weight was the breakthrough as it provided breathing room, transforming a messy cluster into a coordinated, organic herd.

Future Work:

Leader Dynamics: Adding a Leader agent with a stronger Seek force to see if the herd naturally follows its path.

Obstacles: Implementing “Rocks” or “Rivers” to force the herd to navigate around barriers using Obstacle Avoidance steering.

Vision Cycles: A Night Mode where the vision radius shrinks, forcing agents to rely more on Alignment when targets are out of sight.

Sound: Using p5.sound to map the Panic state to a rising ambient hum, making survival tension audible.

One thought on “Assignment 8”

  1. This is such a cool project, I honestly had fun just watching it. What really stood out to me is how natural everything feels, especially when the “Lion” gets close and the herd suddenly splits.

    I really liked how you structured the logic with the hierarchy of needs. The idea that safety overrides everything else comes through super clearly, and your handleInteractions method makes that easy to understand. I believe this mimics nature really well and takes us out of the “just code” mindset and makes the characters on screen really feel alive.

    If I had to suggest anything, maybe you could add a model for a lion instead of just a circle so it feels more natural. Also maybe a feature you could implement would also be the lions ability to eat the animals when it reaches them. This would add an issue of population control but maybe it’s a nice feature to think about.

    Overall, this feels like one of those projects where you can tell a lot of thought went into both the concept and the details. It’s not just technically solid, it’s also really enjoyable to watch.

Leave a Reply

Your email address will not be published. Required fields are marked *