boids
simulate a flock of android birds from Brooklyn
boids -help
or
boids [-width integer] [-height integer] [-num integer]
[-steps integer] [-seed integer] [-angle double]
[-vangle double] [-rcopy double] [-rcent double]
[-rvoid double] [-rviso double] [-wcopy double]
[-wcent double] [-wvoid double] [-wviso double]
[-wrand double] [-dt double] [-ddt double] [-minv
double] [-len integer] [-psdump] [-inv] [-mag inte-
ger] [-term string]
Simulates a flock of boids according to rules that determine their individual behaviors as well as the “physics” of their universe. A boid greedily attempts to apply four rules with respect to its neighbors: It wants to fly in the same direction, be in the center of the local cluster of boids, avoid collisions with boids too close, and maintain a clear view ahead by skirting around others that block its view. Changing these rules can make the boids behave like birds, gnats, bees, fish, or magnetic particles.
Simulate a flock of boids according to rules that determine their individual behaviors as well as the ``physics'' of their universe. A boid greedily attempts to apply four rules with respect to its neighbors: it wants to fly in the same direction, be in the center of the local cluster of boids, avoid collisions with boids too close, and maintain a clear view ahead by skirting around others that block its view. Changing these rules can make the boids behave like birds, gnats, bees, fish, or magnetic particles. See the RULES section of the manual pages for more details.
Rules
All of the rules have a weight option and a radius option. The radius option specifies how close a boid need to be to another in order for the rule to be acted upon. The weight is used when combining all of the rules actions into a single new velocity vector.
The four rules can be simply described as follows:
Centering: move towards the center of any boids in my viewing area.
Copying: attempt to move in the average direction of that all boids that can be seen are moving in.
Avoidance: ``Please don't stand so close to me.'' Move away from any close flyers.
Visual: move in such a way that the bonehead obstructing your view no longer interferes.
The four rules are then normalized and added together to make the next velocity vector of the boid. All radii in the rules are in terms of pixels.
You may wish to try turning on and off different combinations of the rules to see how the boids' behaviors change. For example, if you turn off the avoidance rule, increase the centering radius and weight, and increase the viewing angle to nearly 360 degrees, then the boids will behave like a pack of wolves fighting over the center. Other changes can yield similar surprises.
Bugs
No sanity checks are performed to make sure that any of the options make sense.
Options
-width | Width of the plot in pixels. | 640 |
-height | Height of the plot in pixels. | 480 |
-num | Number of boids. | 20 |
-steps | Number of simulated steps. | 100000000 |
-seed | Random seed for initial state. | 0 |
-angle | Number of viewing degrees. | 270.0 |
-vangle | Visual avoidance angle. | 90.0 |
-rcopy | Radius for copy vector. | 80.0 |
-rcent | Radius for centroid vector. | 30.0 |
-rvoid | Radius for avoidance vector. | 15.0 |
-rviso | Radius for visual avoidance vector. | 40.0 |
-wcopy | Weight for copy vector. | 0.2 |
-wcent | Weight for centroid vector. | 0.4 |
-wvoid | Weight for avoidance vector. | 1.0 |
-wviso | Weight for visual avoidance vector. | 0.8 |
-wrand | Weight for random vector. | 0.0 |
-dt | Time-step increment. | 3.0 |
-ddt | Momentum factor (0 < ddt < 1). | 0.95 |
-minv | Minimum velocity. | 0.5 |
-len | Tail length. | 20 |
-psdump | Dump PS at the very end? | False |
-inv | Invert all colors? | False |
-mag | Magnification factor. | 1 |
-term | How to plot points. | None |