Amal – Assignment 8

Concept

For this assignment, I created a system of multiple vehicles that interact through different steering behaviors. The goal was to move away from simple motion and build something that feels alive, where each agent reacts to both the environment and the other agents around it.

The system is inspired by flocking behavior and Craig Reynolds’ steering behaviors, especially seek, flee, separation, alignment, cohesion, and wander. What interested me most is how a few simple rules can create complex and unpredictable motion when combined.

Instead of representing real-world objects like birds or cars, I kept the visuals abstract. This shifts the focus to movement itself. The vehicles behave like particles with intention, constantly adjusting their direction based on nearby agents and the mouse. The result is a system that feels dynamic and slightly unpredictable.

First Prototype

The first prototype focused only on seek behavior. Each vehicle moved toward the mouse using velocity, acceleration, and steering force.

At this stage, the system worked technically, but it felt very predictable. All vehicles behaved the same way and moved toward the same point, so there was no interaction between them. The motion looked flat and repetitive.

This version helped me understand:

  • how to structure the Vehicle class
  • how steering works using desired velocity minus current velocity
  • how to limit speed and force for smoother motion

It was a necessary step, but it did not yet feel like a system.

Final Sketch

In the final version, I combined multiple steering behaviors. The vehicles no longer only seek the mouse. They also separate from each other to avoid crowding, loosely align with neighbors, move toward a local center through cohesion, and wander slightly to avoid rigid motion.

The mouse interaction also became more dynamic. Vehicles are attracted to the mouse from a distance, but when they get too close, they flee. This creates a push and pull effect that keeps the system constantly shifting.

Because each vehicle balances multiple forces at once, the motion feels more organic and emergent.

Code Highlight
applyBehaviors(vehicles, mouse) {
  let sep = this.separate(vehicles);
  let ali = this.align(vehicles);
  let coh = this.cohesion(vehicles);
  let wan = this.wander();

  let mouseDist = dist(this.pos.x, this.pos.y, mouse.x, mouse.y);
  let mouseForce;

  if (mouseDist < 90) {
    mouseForce = this.flee(mouse);
    mouseForce.mult(2.2);
  } else {
    mouseForce = this.seek(mouse);
    mouseForce.mult(0.35);
  }

  sep.mult(1.8);
  ali.mult(0.8);
  coh.mult(0.7);
  wan.mult(1.1);

  this.applyForce(sep);
  this.applyForce(ali);
  this.applyForce(coh);
  this.applyForce(wan);
  this.applyForce(mouseForce);
}

This part of the code is the core of the system. Each behavior is calculated separately and treated as a force, then scaled using multipliers before being applied. This allows the system to balance multiple influences at once.

From a technical perspective, each behavior returns a steering vector based on desired velocity minus current velocity. These vectors are then combined through applyForce(). Adjusting the weights changes how dominant each behavior is, which directly affects how the system feels visually.

Milestones and Challenges

The first milestone was getting the basic vehicle system working with position, velocity, and acceleration. After that, I implemented seek behavior so agents could move toward the mouse.

The next challenge was that everything felt too uniform. All vehicles behaved the same way, which made the system predictable. I fixed this by adding separation, which prevented the vehicles from collapsing into a single cluster.

After introducing alignment and cohesion, the system became more structured, but also too rigid. To fix that, I added wander, which introduced small random changes and made the motion feel more natural.

Balancing the behaviors was the biggest challenge. If separation was too strong, the system spread out too much. If cohesion was too strong, everything clustered. If wander was too strong, the system became chaotic. A lot of the process involved fine-tuning these weights.

Reflection + Future Improvements

This project showed me how complex behavior can emerge from simple rules. The final motion is not directly designed. It comes from the interaction between behaviors, which makes the system feel more alive.

What worked well is the layering of multiple forces. Each vehicle is simple on its own, but together they create a dynamic system that constantly changes.

For future improvements, I would introduce different types of agents with different behaviors, such as leaders or more reactive agents. I would also add environmental constraints like obstacles so the system reacts to space in a more complex way.

Another direction would be to develop the visual side further, such as adding trails, color variation, or changes based on speed and proximity.

 

Leave a Reply

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