# Boids Sandbox Boids describes a flocking algorithm where there is no single leader, but each member of the flock moves according to well defined rules. The rules are as follows: Separation: A force that tries to keep boids from getting to close to each other. Applies a vector to each boid pointing away from any boids within the separation_distance. Cohesion: A force that attempts to keep all members of the flock close together. Applies a vector to each boid that points towards any that are inside of the cohesion_distance. Note that this force is completely opposite the separation force, but operates with a larger range. Alignment: A force that keeps all members of the flock pointing in the same direction. Applies a force to each boid with a normalized vector pointing in the same direction as any boids within alignment_distance. By applying these rules to each boid each clock tick, we generate organic flocking behavior. ## Dependancies This program require the pyglet module to run. Install using easy_install: easy_install pyglet ## Usage Run the simulator using Python: python boids.py There are modifiable parameters in the start of the script for changing window settings and flock statistics (number of boids, etc). A user wishing to play with the flocking algorithm parameters can do so in apply_flock_forces(boid). This function determines and applies the vectors that will effect a given bird. The parameters in apply_flock_forces() modify how much weight a given rule is given, and how close a boid has to be to be affected by that rule. For example, setting the separation_distance or separation_weight to 0 will turn off that rule completely, making sure that it applies no forces to the boid. ## More information There is numerous resources online about Boids, including a good Wikipedia article. I have written a blog post about this project at http://blog.tophernet.com/2011/03/boids-sandbox.html. It contains a higher look at the project, as well as some screenshots. ## License Copyright Topher Brown <firstname.lastname@example.org>, 2010. Released under the MIT license.