Skip to content

Have you already implemented the boids simulation algorithm? So now it's my turn!

Notifications You must be signed in to change notification settings

ZERDICORP/boids_simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

boids_simulation 🐦 🐟

Have you already implemented the boids simulation algorithm? So now it's my turn!

What it is? 🙋

Oh, brother, this is just unrealistically cool algorithm!

Its essence is to imitate flock behavior.
That is, having some kind of abstract agents, we can make them move in flocks (like a large group of birds, fish or other animals).

I had a lot of fun implementing this algorithm. It amazed me how such simple logic could lead to such magic!

How it works? 😯

This algorithm is based on damn simple logic.

Suppose we have so-called agents that have a location in two-dimensional space and a velocity represented by a vector.

Now we need to go through each of the agents and apply some set of rules to them:

  1. Cohesion (an agent tends to the center of the flock);
  2. Separation (an agent keeps a distance from other agents);
  3. Alignment (an agent tends to move at the same speed as other agents).

That's all!

How exactly to implement these rules in the code is a secondary issue.
Most importantly, we have agents and a set of rules that they must follow.

If you want to learn more about the boids simulation algorithm, I advise you to read the following articles:

Features 🌟

Interaction with the flock

You can simulate the presence of a predator with your mouse.
To do this, hold down the left mouse button and, without releasing, move it near the agents.

spoiler

2022-06-12 21-06-52

Demo 😻

About

Have you already implemented the boids simulation algorithm? So now it's my turn!

Topics

Resources

Stars

Watchers

Forks

Languages