Predator Escape

A simple model that depicts how boids perceive and escape predators

This real-time simulation is computationally complex and may induce unresponsiveness on lower-end devices

(If the simulation hasn't started then please hover your pointer over the canvas)


Details

Meaning of boid colors:

  1. Light Blue: The boid hasn't detected any predator. The predator may lie in its blind spot, or it may be far away.
  2. Green: The boid has detected the predator, but the predator is not that close
  3. Red: The boid has detected the predator, and the predator is close enough to be a threat
Now, we have two instincts at work here: (a) Collective Behaviour and (b) Predator Avoidance. In order to understand the dynamics of Collective Behaviour, please visit this page. The dynamics of predator avoidance is simple: go in the opposite direction of predator approach. The main question is, how do we make these two behaviours operate together? We define a lower radii \(r_1\) and an upper radii \(r_2\). Let the distance of the predator from the boid be \(d\), and assume that the predator does not lie in the blind spot of the boid, then:
  1. \( d < r_1 \): Predator avoidance will dominate the boid's behaviour
  2. \( d > r_2 \): The boid will continue to follow the rules of collective behaviour
  3. \( r_1 < d < r_2 \): The boid will follow a weighted average of predator escape and collective behaviour. The weight of predator escape 'w' is given by: \[ w_p = \frac{d - r_2}{r_1 - r_2} \] The weight of collective behaviour is therefore \(w_c = 1 - w_p\). The boid will seek to move in the direction given by the weightage average of these two instincts.
If the predator lies in the blind spot of the boid, then irrespective of the value of \(d\), the boid will continue following the rules of collective behaviour since it has not detected the predator.


Note:
  1. This simulation is preferably viewed on a desktop/laptop.
  2. The method of combining both behaviours is inspired by a similar method in molecular dynamics: in order to reduce the time complexity of molecular simulations from \(O(N^2)\) to \( \approx O(N) \), one can cutoff the operating potential at some distance \( r_c \). However, this causes the force to be discontinuous at \( r_c \). This problem presents itself in the form of anomalous acceleration of individual molecules. In order to remedy this, one defines two radii \( r_1 \) and \( r_2 \), and brings the potential down to zero between these two radii in a smooth manner using switching functions of various degrees.

Developed by ChanRT | Fork me at GitHub