Flocking. Sperm. Sperm flocking.That got you to click didn’t it? Everybody loves sperm! Well, if you don’t you’ve got to at least acknowledge it’s an integral building block of human life. Good news, you’ll get to see some sperm below. Bad news, it’s not all that erotic. Now, back to sperm flocking. What does that mean. Well, flocking is a behavior exhibited by birds. The behavior was formalized into an algorithm and simulated on a machine by Craig Reynolds in 1987.
The layperson knows what it means to flock. You’d be hard pressed to find a person that hasn’t heard the saying
Birds of a feather flock together
or knows what it looks like when beards flock. But the average person cannot describe to you what it means for a bird to flock. They cannot formulate the characteristics of flocking flight as opposed to regular flight.
Flocking behavior has three key tenants:
Separation states that a bird will steer itself so as to avoid crowding fellow flockmates.
Given a radius, a bird (or boid as coined by Reynolds original software) will head in the opposite direction of the summation of the vectors generated by calculation the distance from each other flockmate in the bird / boid’s neighborhood. The red vector is the delta velocity vector calculated based on the other boids in the neighborhood.
Alignment states that the boid will steer towards the average heading of local flockmates. Below is the delta velocity vector generated based on the heading of the other flockmates in the neighborhood..
Cohesion states that a boid will steer to move toward the average position of local flockmates.
Here the delta velocity vector steers the boid towards the center of the position of flockmates in our boids neighborhood.
Below we see the sperm as they exist peacefully without any applied flocking algorithm.
Now we have my added flocking code. Note that the sperm head transform is broken and needs to be fixed. You can see how the sperm flock in groups, stay separated from one another and yet align their headings to those of their nearest neighbors.