🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Boid's algorithm doesn't work perfectly

Started by
3 comments, last by pr033r 6 years, 6 months ago

Hello,

I have a Bachelor project on topic "Implenet 3D Boid's algorithm in OpenGL". All OpenGL issues works fine for me, all rendering etc. But when I started implement the boid's algorithm it was getting worse and worse. I read article (http://natureofcode.com/book/chapter-6-autonomous-agents/) inspirate from another code (here: https://github.com/jyanar/Boids/tree/master/src) but it still doesn't work like in tutorials and videos. For example the main problem: when I apply Cohesion (one of three main laws of boids) it makes some "cycling knot". Second, when some flock touch to another it scary change the coordination or respawn in origin (x: 0, y:0. z:0). Just some streng things. 

I followed many tutorials, change a try everything but it isn't so smooth, without lags like in another videos. I really need your help. 

My code (optimalizing branch): https://github.com/pr033r/BachelorProject/tree/Optimalizing

Exe file (if you want to look) and models folder (for those who will download the sources):

http://leteckaposta.cz/367190436

Thanks for any help...

Untitled2.png

Advertisement
19 minutes ago, pr033r said:

I have a Bachelor project on topic "Implenet 3D Boid's algorithm in OpenGL".

I envy you, what a great topic.

22 minutes ago, pr033r said:

I read article (http://natureofcode.com/book/chapter-6-autonomous-agents/) inspirate from another code

This could be your problem, your starting way too deep. Complex subjects should be eased into.

This article was better for me than most of the stuff on the web: http://www.kfish.org/boids/pseudocode.html

It shows a concept where you design the rules separate then add them, it's a easy way to prototype your own boid set. Then later when everything works you can merge them into a efficient rule.

30 minutes ago, pr033r said:

Second, when some flock touch to another it scary change the coordination or respawn in origin (x: 0, y:0. z:0). Just some streng things. 

I had something similar happen but it was because of avoidance, when a boid got near a other they would rush to the 0,0 point. When I looked I found that my avoidance subtraction was reversed:

Instead of BoidA.position - BoidB.position I was using BoidB.position - BoidA.position. Look around to see if the same thing isn't happening with you.

Solving the math on paper was a good way for me to solve problems.

 

I haven't had a chance to look at your code, having a long work day.

Thanks for reply. I tried to change argument position of subVectors method but it still doesn' work.

So, now I try code it, by that pseudocode... hopefully it'll work.

Ok, I figure out it that all problems are in Seperation method. If I comment this method, all works smoothy, without lags, even when 100 boids is set. Now I have to find solution how to define ideal seperation method.

This topic is closed to new replies.

Advertisement