Jump to content
  • Advertisement
pr033r

Boid's algorithm doesn't work perfectly

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!