I have an implementation here [0] if people want to play with it. Supports dynamically changing the controls, has obstacles and predators. Setting weights for separation, alignment and cohesion to zero and then increasing only one of them nicely shows which role each of them plays. It's actually made as a workshop [1] for my company, where the shell is provided and one has to implement it step by step. In Norwegian, though.
Update: Dang linked other discussions, and I see I commented on one from 2015 [2]. Someone there asked for the course content, and that's available (in English!) in a PDF in [1]. This workshop/implementation is actually an example of what I wanted the students to make at the time. Which I then retrofitted to a fun workshop for my colleagues.
Works great on my phone. I noticed that flocks tended to split when they wrap around the edge of the field, as if forces weren't being computed wrapped. Makes it hard to accomplish my goal of merging all the boids into a single flock :).
Yeah, the neighbourhood calculation doesn't wrap around. That's trivial to add, but then one has to account for the wrapping when calculating average neighbourposition so it's not completely off. Not too hard, but would have added complexity to the workshop.
These guys behave just like the implementation I wrote! I worked out how to do separation, cohesion, and alignment based on written descriptions as an exercise.
Update: Dang linked other discussions, and I see I commented on one from 2015 [2]. Someone there asked for the course content, and that's available (in English!) in a PDF in [1]. This workshop/implementation is actually an example of what I wanted the students to make at the time. Which I then retrofitted to a fun workshop for my colleagues.
[0]: https://matsemann.github.io/boids-workshop/ [1]: https://github.com/Matsemann/boids-workshop [2]: https://news.ycombinator.com/item?id=9300142