Marc Bucchieri is a KTBYTE Instructor who teaches Fundamentals and CS-level classes. In his free time he enjoys creative cooking projects and exploring new places.
I like to spend a lot of my time outside. Something that’s fascinated me for years is the way many organisms can move together, as if one intention was controlling the entire group. It seems like everything from fish to bees to even moths can be seen moving together under the right conditions. It wasn’t until I became passionate about biology and computer science that I learned that these patterns fall in the category of collective motion, and that there’s a whole field of study related to them!
What is collective motion?
“Collective motion” is a term used to describe the ordered movement of many individual agents acting as a group. This motion is a type of emergence, or emergent behavior. Emergence occurs when a group has properties that each of its parts do not have on their own. This idea shows up all the time in nature, from cells and bacteria to beehives and flocks of birds.
With all of these potential applications, it’s no surprise that scientists would be interested in modeling this behavior accurately. Perhaps the most famous model was introduced by Tamás Vicsek et al. in 1995. This team of Hungarian physicists used fairly simple mathematical rules to describe a system in which particles showed emergent behavior for low values of noise. This model was first used to study the phase transition of matter from a gas state with disordered motion to the collective motion of liquid molecules!
Rules for Emergent Behavior
Perhaps the most popular applications of modeling collective motion show up in movies and video games. Craig Reynolds created a simulation of “boids”, or bird-like objects, in 1986 and used it in the movie Batman Returns in 1992. His model was based on three rules for how the individual boids should interact: cohesion, alignment and separation.
The way these rules work is actually pretty simple to understand, and not too much harder to code! Cohesion means that each boid will move towards the center of other boids within a certain distance. Alignment means that boids will try to fly with the same angle as nearby boids. And separation means that each boid will move away from others within a certain distance, to keep from getting too crowded.
Collective Motion at KTBYTE
As a KTBYTE Instructor I’ve been excited by the idea of adding classwork material that can explain and teach emergent behavior. This is a topic that may seem complex or intimidating when people first hear about it, but breaking the problem down into simple parts helps make it accessible for almost any of our students to explore. Recently I developed versions of the Boid algorithm for our class groups to work with in either JavaBlocks or Processing. This code uses KTBYTE’s custom Sprite library, which students often use to code games and character interactions in their projects.
You can play around with this project by clicking here to visit its project page. It allows you to change the parameters that control the range each boid uses to achieve cohesion, alignment, and separation with its neighbors. You can also click anywhere to add a new boid. As students work with this project they’ll be able to influence how much each parameter effects the output, add some random behavior or noise, and even write their own rules!
Not only is this kind of modeling a lot of fun, but it also has widespread applications. The principles of emergent behavior are currently being used to further our understanding of complex systems, from microorganisms and neural networks to social dynamics and the weather. Our hope in teaching this content is that students who get excited about this branch of computer science will be able to continue exploring it for the rest of their lives.