Flocking Simulation

Technical Skills:  Java; Flocking Simulation; Finite-state Machine; Artificial Intelligence; C++;

Screenshot_2016-08-02-12-33-35

The project was to produce a flocking simulation. The flock (yellow) attempts to flock around the alpha (white) while evading the predator (red) who is seeking the alpha.

The AI in the simulation is built on a finite state machine so the appropriate behaviour is selected depending on certain key factors. The implemented behaviours are: seek; evade; wander; and align.

The basic logic for the finite-state machine for each agent is described below:

  • The predator
    • seeks the alpha.
  • The alpha
    • evades from predator if it gets too close,
    • otherwise it wanders/continues at current velocity.
  • A follower
    • evades from predator if too close to predator,
    • evades/separates from alpha if too close to alpha,
    • aligns to the leader if close enough (factors the alpha’s velocity into its own velocity calculations),
    • Seeks/cohesion towards the alpha if too far away from alpha for alignment to occur,
    • otherwise wanders/continues at current velocity.
    • Additionally, evades from other followers to avoid collisions if too close together (not part of the finite state machine).

The project was originally written for Windows PC in C++. A version was rewritten in Java and included in the James Potts Portfolio app released on Google Play Store in August 2016.