It is made for describing flocking behavior.
You can build it by Visual Studio 2019 (different versions can cause some problems.) or you can just run x64\Release\opencvtest.exe.
When I visited Kyoto Aquarium(October 12, 2019), I saw lots of tiny fishes that moved with synchronization. I was inspired by that, so I have tried to find a way how I can describe it.
If you do not have Visual Studio, then you need to install Visual C++ Redistributable. Here is the link (https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads)
Build the code or just run x64\Release\flocking.exe
Q button : adding one creature
W button : removing one reature
mouse right button : attracting creatures
mouse left button : repulse creatures
I hope you enjoy it!
There are three rules.
- separation among creatures. Within a specific distance, creatures try to break away from others.
- alignment among creatures. Within a specific distance, creatures try to get average velocity and orientation with others.
- cohesion among creatures. Within a specific distance, creatures try to go to the average point of others.
Moreover, I added an additional rule for evading wall and mouse control (repulse and allure to mouse)
These are the photography which I took on kyoto aquarium. You can see tiny fishes moving on the tank.