Boids
Boids algorithm is an artificial life algorithm proposed by Craig Reynolds in 1986, used to simulate the behavior of bird flocks, fish schools, etc. Boids algorithm simulates the interaction between individuals to achieve collective behavior of the group.
Terminology
In the Boids algorithm, we have the following terminology:
- Boid: An individual in the group
- Perception: The radius of the area around a boid that it can sense
Rules
In the Boids algorithm, we have the following rules:
- Separation: A boid should avoid crowding nearby boids
- Cohesion: A boid should move towards the center of mass of nearby boids
- Alignment: A boid should move in the same direction as nearby boids
Demo
Here is a demo of the Boids algorithm. You can adjust the parameters to see how the boids behave.
- Count: Number of boids in the simulation
- Perception: Radius around a boid that it can sense
- Separation: Force pushing a boid away from nearby boids
- Cohesion: Force pulling a boid toward the center of nearby boids
- Alignment: Force aligning a boid’s velocity with nearby boids
- Highlight: Toggle to highlight the first boid and show its perception range
Count:
1
Perception:
0
Separation:
0
Cohesion:
0
Alignment:
0
Highlight:
Interesting things
Actually, I think these three rules also exist in human society to some extent. So we can run some interesting experiments, such as:
- Perception: In earlier societies, before the rise of the internet, people had a much narrower field of view. They could only pay attention to their own small world — their village or tribe. Back then, there was greater diversity, and individuals were less influenced by broader societal norms. After the explosion of information, it’s much easier for a “mainstream” to emerge, and people tend to become more homogeneous in their thinking.
- Separation: This is somewhat similar to the modern concept of boundaries. For example, if someone asks you how much you earn per month — in some societies, that’s totally normal, but in others, people would think there’s something wrong with you. In societies with weak boundaries, people are more likely to form tight-knit communities and feel a stronger sense of belonging. In contrast, in societies with strong boundaries, individuals tend to be more independent, but it also becomes harder to truly connect with others.
- Alignment: I think this has to do with how stable the hierarchy is within a group. When alignment is low, people are not necessarily expected to follow the mainstream path. Yet, the group still tends to move in a cohesive direction, while allowing for shifts in internal positions. On the other hand, when alignment is high, not only does the whole group move in the same direction, but the relative positions of individuals within the group also tend to stay fixed.