Title Population Flocking, Sketch link
Project Summary
At first stars populate the screen randomly. Then they begin to form clusters, flocking, or moving, together. If there’s too many stars in a group, that group faces overpopulation and each star in that group is more inclined to separate from the group. However, if there are too few stars in a group, the group is in a state of underpopulation. When a star is in underpopulation, each star is more drawn to its surrounding stars and has a larger perception radius when searching for other groups to join.
Each star also has a life force. When in a state of overpopulation or underpopulation, the star’s life force decreases. However, when the star is in a stable population group, its life force increases. If the star is at full health for a duration of time, a new star will be born near it. However, if the star loses all its health, the star burns out and dies.
Overtime, the stars also learn how much to navigate between population states better, as long lasting stars, or those with higher life forces for longer periods of time pass on information to new generations about how much to separate from and overpopulated group and how to better find other stars when underpopulated.
Process
The base of this simulation is the flocking behavior, which I created by following along Coding Challenge #124: Flocking Simulation.
In the Craig Reynold’s flocking simulation, the behavior of particles, called boids, is primarily a steering force and it’s guided by 3 rules - alignment separation, and cohesion. Boids steer towards the average direction of local flockmates, steer to avoid crowding local flockmates, and steer to move towards the average position of local flockmates.
Next, I combined rules from Coding Challenge #85: Game of Life to the behavior of boids.
In John Horton Conway’s Game of Life, cells of a grid have a state of life or death, which is influenced by the number of its neighbors. If the cell has less than 2 live neighbors or more than 3 live neighbors, it will die. However, if the cell has 2 or 3 live neighbors, it will live on to the next generation. Lastly, any dead cells with 3 live neighbors becomes a live cell. These rules were modeled after underpopulation, overpopulation, and reproduction.
In my project, I connected the idea of neighborhoods and flockmates, using the number of live neighbors as the number of local flockmates a boid detected in its perception radius.
Following through with the analogy, I combined the rules of each simulation. If there are more than 3* local flockmates, the boid is facing overpopulation. If there are less than 2* local flockmates, the boid is facing underpopulation. However, rather than changing the life or death state of a boid that a cell undergoes in either state, I influenced the separation and cohesion forces guiding the boid’s steering behavior. Then, if the boid is facing underpopulation, they will be more inclined to steer towards other flockmates, and if the boid is facing overpopulation, they will be more inclined to steer away from local flockmates.
I added the concept of life force to use as a condition for life and death. Life force decreases when in a state of over or under population for a duration of time. However, it increases otherwise (i.e., in a stable flock). Once life force is depleted, the boid dies. But being at full health for a period of time can create a new boid near it.