After binge watching The First, I wanted to see how hard it would be to visually simulate the “flock of birds in the sky moving around” the director created as a gift for her child. It’s been a long time since I’ve wrote code with visual output, and even longer since grade school apparently - murmuration was the result of a few embarassing google searches.

Some searching and wikipedia lookups yieled this 90s themed repository, which lead to this paper, which lead to this javascript implementation.

I did not want to “cheat” and realized what I wanted was a “textbook” describing “how do murmations work”. The techentaur repo linked to this amazing find: “Mathematical modeling of flocking behavior”.

To scratch a FP itch, I decided to use erlang and elixir and found this great post on how to write a gui in elixir which lead to scenic.

The end result was a few hours of joy in the pipe and immutable constructs of Elixir/Erlang and a somewhat realistic visualization of flocking behavior. Note the gif resolution is poorer than the native scenic run:

gif of bird murmuration gif

The source code for the simulation can be found here.