Live Coding: Swarm Behaviour in Elm

To simulate a basic swarm behaviour, you only have to implement three rules:

  1. If my closest neighbour is too far away, move toward him.
  2. If my closest neighbour is too near, move away from him.
  3. Otherwise, move in the same direction as my closest neighbour.

I implemented these rules in Elm during a live coding session. You can find the result on Github.