Skip to content

brenocq-atta/boids

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Boids

This repository will contain different implementations of boids. For now, only the basic 2D implementation has been done.

The algorithm

The first publication of Boids was made in 1986 by Craig Reynolds, and it consists of multiple agents intecting with each other to generate a flocking behaviour. The algorithm consists of 3 simple rules: Separation, Alignment, Cohesion.

Separation:

Agents avoid being too close to each other.

Alignment:

Agents align their angle with those of neighbors.

Cohesion:

Agents move to the center of their neighbors.

Each agent is represented as a vector, and the each rule generate a vector that is summed to the agent's vector.

Implementation

Implementation of 2D boids with obstacle avoidance. Each boid is represented as a 2D vector. The force is given by:

Force = collisionAvoidance * collisionAvoidanceFactor + 
        velocityMatching * velocityMatchingFactor + 
        flockCentering * flockCenteringFactor + 
        obstacleAvoidance

The following parameters can be changed from the UI:

  • collisionAvoidanceFactor: How strong the collision avoidance will be. Can be used to adjust how close each agent will be from each other
  • velocityMatchingFactor: How strong the collision avoidance will be. If set to zero, agents will follow different directions.
  • flockCenteringFactor: How strong the flock centering will be. If set to zero, agents will always avoid each other.
  • viewRadius: How big is the agent view radius. Boids inside the view radius are considered neighbors.
  • noise: Add random noise to neighbors readings.

Obs: Obstacle avoidance was implemented to avoid two types of objects:

  • Walls (4 predefined entities)
  • Disks (entities with mesh component set as disk)

Features

  • You can move the walls while the simulation is running.
  • Turn on world force field plot (obstacle avoidance force).
  • Inspect position/velocity plot of selected boid.

References