Alpha Boids

Flocking and various emergent behavior from flocking

The project is about demonstrating emergent behavior in flocking systems and how relatively simple rules can bring about complex behavior among boids (members of flocks).

Here is a screen shot of my project:

The text on the page behaves as a flock of moving objects that move freely on the 2D plane of the paper and do interesting things like avoid or move toward obstacles depending on what kinda attraction they have over each other.


Platform used

I have used the Electro rendering engine which takes Lua scripts as input for my implementation. On hindsight, this seems to be a bad idea to me as performance is severely limited by Electro's capabilities. This is also another reason why the number of boids in the flock is relatively low. This is however not an inaccurate representation of a flock as real-life flocks are of similar sizes with typically less than a hundred individuals. A flock with more than that number of individuals could be categorized as a swarm rather than as a flock.

Rules that are implemented

The following rules have been implemented in guiding the flocking behavior of this implementation:-

  • Cohesion - Move towards the center of the flock. This can be increased or decreased by using the 'm' and 'n' keys
  • Privacy - Make sure the boids don't hit each other
  • Match Velocity - Here velocity is a vector and hence, both direction and speed are matched with all the members of the flock
  • Bounding Regions - This has been implemented purely for the benefit of the viewer who is viewing the flocking behavior
  • Goal following - The flock in this implementation moves primarily only towards its goal which is changed frequently to keep the flock moving all the time
  • Avoiding obstacles/danger - The flock also avoids mines that drop from the global pool of many more characters which are hanging above. Use the 'p' and 'o' keys to increase or decrease the magnitude of fear

Source Code and Executable

You will need Electro to be able to run the following implementation:-

Source + Executable

Just double-click the Electro.bat file in the Project 2 folder and it will load

The following key combinations must be noted;

  • UP_ARROW - Forward move the camera
  • DOWN_ARROW - Backward move the camera
  • LEFT_ARROW - Left move the camera
  • RIGHT_ARROW - Right move the camera
  • 'a' - moves the camera up
  • 'z' - moves the camera down

Questions

Question from Chaitanya Kamisetty

Q: I observed that all the boids collide with the wall and change their direction. But, if the velocity matching principle is applied I would expect the flock to smoothly steer away from the wall. Could you explain?

A: You are right. If I were to apply only the velocity matching principle then I would see that they smoothly veer away from the wall. But, there are two things you have to consider here that affects their behaviour as you see.

  • The wall is not an obstacle but a goal that have to reach
  • Also, velocity is not the only force acting on them, the urge to go toward the goal is always higher than the directional urge of velocity (velocity is comprised of both direction and speed). This makes them reach the goal and then do the match velocity that we are able to see.

I hope this has answered your question to some extent.

Post Presentation

After I saw some of the other projects which had implemented hunter-prey relationships, I realized that I could do that with my boids pretty easily and this really got me going and I implemented a dynamic obstacle avoidance system where the boids avoid the threat which comes nearer and nearer to them.

You can download this version along with source code here.