I did something very similar some years ago while learning metal [1], I recall them being called "boids". I spent days just playing with the various parameters, luckily my implementation was not as pretty as the one offered in the OP, otherwise I would have lost weeks instead.
The original boids, or "bird-oid objects", was an algorithm and program to simulate emergent flocking behaviour from simple rules in birds. It has spawned a kind of genre, or at least a multitude of copies/derivatives, often collectively referred to as "boids".
I've been vibe coding boids implementations because my toddler likes to look at them. Here's one where the attributes of the boids (alignment, etc) are hooked up to frequency generators like a sequencer: https://neuroky.me/boidsine.html?boidCount=1700&hue=sine3&se...
I can move them to GitHub or something, but they are currently hosted in my pantry. Please be gentle :)
[1] https://github.com/ghyatzo/metalplay?tab=readme-ov-file