Sign in to follow this  

2d flocking theory

This topic is 2846 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to give 2d flocking behaviour a try. The three main rules are listed on wikipedia but I need some elaboration on the theory. If I understand wikipedia correctly I need to execute these three steps, in order, every frame. rule 1 - seperation Spring targets away from eachother if within a certain radius. rule 2 - alignment steer left/right towards avarage of total group direction/angle. rule 3 - cohesion steer left/right towards center of nearest neighbours. How do I influence the group direction? Do I need some sort of indipendant group leader to indicate the desired direction? Otherwise, wouldn't they just be flying straight to the eventual average of eachother? Meaby a step 0: to steer left/right towards target direction? And where does object avoidance behaviour fit into these rules?

Share this post


Link to post
Share on other sites
Short answer, you still need to give your boids something to do -- avoidance or seeking are most common.


Long answer, did you find Craig Reynold's site on Steering Behaviors?
http://www.red3d.com/cwr/steer/

He has code, an in-depth paper, and demos!

Share this post


Link to post
Share on other sites
I use a scoring algorithm for this where priorities are assigned to many different qualities of behaviour.



Each 'action' in a list of actions is scored (in this image, the boids are following the normal boid rules, as well as hunting for edges in the source image. The action list contains alterations of heading and propulsion; each action is run for a few simulation steps (seekahead) evaluated for score; then the actions are blended, based on their score.

It's a fun system, since you can evoke new behaviours by conceiving of new rules as long as they can be deterministically scored. I can make the boids match a cruising speed, avoid their neighbor's crusing speed, search for edges, search for specific colours, cluster to large groups, attempt to distribute evenly across the simulation field...

It's also cool because the underlying physics can be arbitrarily complex and the boids will still try to minimize their score within that system. Wind, gravity, obstacles etc. require very little modification to the boids themselves, since all they concern themselves with is heading and thrust. (The basic physical model I'm using is a circular object with a swiveling thruster)

Share this post


Link to post
Share on other sites

This topic is 2846 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this