(last updated: )
Live Coding: Swarm Behaviour in Elm
To simulate a basic swarm behaviour, you only have to implement three rules:
- If my closest neighbour is too far away, move toward him.
- If my closest neighbour is too near, move away from him.
- 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.