HT5Boids - Yet Another Boids Simulation In HTML5

Status

Width: Height:
Type 1
Number Colour Speed Max Turn Edge Avoid Distance Edge Avoid Multipler Edge Avoid Max Turn Collision Avoid Distance Collision Avoid Multipler Collision Avoid Max Turn Match Heading Multiplier Match Heading Max Turn Towards Flock Multiplier Towards Flock Max Turn Towards Flock Forecast Multiplier Towards Flock Forecast Max Turn Towards Flock Forecast Time Local Flockmate Number Local Flockmate Max Distance Flock with same type only Random Turn Factor (Gaussian) Random Turn Factor (Cauchy)

Type 2
Number Colour Speed Max Turn Edge Avoid Distance Edge Avoid Multipler Edge Avoid Max Turn Collision Avoid Distance Collision Avoid Multipler Collision Avoid Max Turn Match Heading Multiplier Match Heading Max Turn Towards Flock Multiplier Towards Flock Max Turn Towards Flock Forecast Multiplier Towards Flock Forecast Max Turn Towards Flock Forecast Time Local Flockmate Number Local Flockmate Max Distance Flock with same type only Random Turn Factor (Gaussian) Random Turn Factor (Cauchy)

Type 3
Number Colour Speed Max Turn Edge Avoid Distance Edge Avoid Multipler Edge Avoid Max Turn Collision Avoid Distance Collision Avoid Multipler Collision Avoid Max Turn Match Heading Multiplier Match Heading Max Turn Towards Flock Multiplier Towards Flock Max Turn Towards Flock Forecast Multiplier Towards Flock Forecast Max Turn Towards Flock Forecast Time Local Flockmate Number Local Flockmate Max Distance Flock with same type only Random Turn Factor (Gaussian) Random Turn Factor (Cauchy)

Type 4
Number Colour Speed Max Turn Edge Avoid Distance Edge Avoid Multipler Edge Avoid Max Turn Collision Avoid Distance Collision Avoid Multipler Collision Avoid Max Turn Match Heading Multiplier Match Heading Max Turn Towards Flock Multiplier Towards Flock Max Turn Towards Flock Forecast Multiplier Towards Flock Forecast Max Turn Towards Flock Forecast Time Local Flockmate Number Local Flockmate Max Distance Flock with same type only Random Turn Factor (Gaussian) Random Turn Factor (Cauchy)

Description

Boids of a feather flock together! I've set up a Boids simulation, based on Craig Reynolds original concept, and added lots of parameters to tweak, and the option of having up to four types of boid. It's possible to tweak the parameters for each type of boid; also, boids with the "Flock with same type only" option selected will only steer towards, and match aligment with, boids of their own type.

It seems that there are (at least) two ways to get boids to self-sort into flocks of a single variety - either by using the "Flock with same type only" option, or by adjusting the parameters so that different types have different parameters. One simple thing to try is speed; if you have fast boids and slow boids, then fast boids are likely to go off and form a group of their own.

Alternative Flocking Mechanism - the classic boids uses three mechanism to create flocking. One is a mechanism to avoid collisions, one is to turn the boids towards the "local flock" (i.e. the closest few other boids), and one is to turn the boids to match the average heading of the "local flock". However, it is possible to replace the last two of these with a single unified mechanism. Turn "Match Heading Max Turn" and "Towards Flock Max Turn" to zero to deactivate those two, then turn "Towards Flock Forecast Max Turn" up to 5.

The alternative mechanism is a lot like the old mechanism which turns the boids towards the "local flock" - i.e. the average position of the closest few other boids. However, instead of considering the position right now, it makes forecasts as to where the other boids will be in a small number of frames - ten by default, and turns towards the average of those forecasts. In effect, if the nearby boids are widely scattered, or pointing in many different directions, then this will have a similar effect to just going to where the boids are. However, if the boids are close together and all pointing in roughly the direction, this will point the boid towards where nearby boids are going. The "forecast" is very simple - it just assumes the boids will keep going forwards in a straight line. It's close enough to give the desired effect.

Peter Corbett, 2014


Back to ptc24 labs.