PySwarm Wiki

Back to PIA's main page

Cohesion V2.jpg


When COHESION is activated, a BOIDs will attempt to move towards the flock’s center of mass (the average of all BOIDs’ positions, except it's own position). When the Localize Rules parameter is set, the local center of mass is calculated by only considering those other BOIDs with the defined radius. Note that this is not the precisely same as being attracted to other BOIDs, but towards a point at the group's center.

Cohesion Graph.jpg

Activate COHESION Rule[]

Check this box to active the rule.

Cohesion Strength[]

Adjust this value to influence the strength of cohesion. Higher values will force the BOIDs to stay close to the group’s center of mass.

Tips and Limitations[]

  1. If COHESION is deactivated, this parameter has no effect.
  2. A value of 1.0 is a "nominal" value. A value of 2.0 will create twice the force, while a value of 0.5 will create half the force.
  3. Negative values will have the opposite effect - forcing BOIDs to move away from the center of mass.
  4. The "Localize Rules" parameter works on this rule. When set, the center of mass for each BOID is calculated only based on those within the Localize Radius.


Most animals are affected by cohesion - the desire to not move too far away from others of its kind.

For simulating some species that are "loners," set the Cohesion Strength parameter to a negative number (e.g., -0.5).