Get Java, you bastard.

Quick info: Spacebar adds birds, 'P' pauses  /  Source code: flock02.jar

  1. 'Spacebar' and '+' (or '=') keys add birds. Hold them down for a nice effect.
  2. 1 toggles the Cohesion flocking behavior
  3. 2 toggles the Separation flocking behavior
  4. 3 toggles the Alignment flocking behavior
  5. Q toggles the display of the gray 'vision' circle
  6. W toggles the display of the green 'friendliness circle
  7. E toggles the display of the light green 'steering' vector
  8. F toggles whether or not the circles are filled. Note: this looks nice, but it is s-l-o-w
  9. P pauses the simulation
  10. '>' (the right arrow key) updates the simulation by one step (when it's paused)

An explanation of what you're seeing might be in order. This is my first successful implementation of Craig W. Reynolds' Flocking Behavior. It is not a very good implementation, but I'm extremely pleased with it.

What you should be seeing above this text is a lot of little brown dots swimming around. If you watch them, you should notice that they are forming and maintaining flocks. The flocks are formed based on three simple steering rules: Cohesion, Separation and Alignment.

In the model above, you can enable or disable the three steering rules by pressing the number keys 1, 2 and 3. Some interesting behavior emerges if you only have combinations of the three on. You can also turn on and off the drawing of the birds vision, friendliness and steering vector by pressing the keys Q, W and E.

If you have turned on the drawing of vision (Q) you should see a lot of gray circles around the birds. The birds can only see other birds that are inside that circle, so they will only react to (and flock with) those birds. If you have turned on the drawing of friendliness (W), you should see a lot of green circles around the birds. That is each bird's comfort zone, so if any other birds get too close, evasive action is taken.

I don't really want to explain it any more... I think I've already made this relatively simple idea pretty murky. If you want to know more, visit the aforementioned web site.

A quick rundown of my past run-ins with what I call "organic motion":

  1. Organic01 - not good
  2. Raindrops - good idea, horribly programmed
  3. Physics03 - weird, but better than the previous
  4. Organic04 - really good, and an original idea, but not up to my standards (the organisms were unaware of each other, so it was really just random motion, like the others, even though it looks fairly organic)

As always... Back to Humor Tree!