Flocking Swarm Applet


Alex S.

[SwarmApplet.java] [BufferedApplet.java]


These rules can be contradictory. Applet uses weighted sums to implement Alignment and Cohesion, and a hard number (six) to implement Separation. If there are six or more flock mates, the weighted sum is 0.3 for Alignment and -0.7 for Cohesion (in other words, try to move away from the center). If there are less than six flock mates, the weithed sum is 0.8 for Alignment and 0.2 for Cohesion. (with some random noise added for interesting effects...)