• Advertisement
Sign in to follow this  

Boids

This topic is 4728 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have to do a final project for my engineering class (computer programming) and earlier I asked for ideas on programs. I wanted to do something with graphics. I decided to do a program using Boids, in SDL or ALLEGRO. I have never used ether though. So if there are any tutorials on either them i'll be greatful (ie. how to code in it and for BOIDS). I need to pick one so I can start ASAP. I have about 7 weeks to finish it. If you think I can't finished that in 7 weeks then what about making a program to draw 3D geometric shapes and rotate them or drop them and see the physics. Thanks for the help.

Share this post


Link to post
Share on other sites
Advertisement
You can get a TON of help on allegro from Allegro.cc there is a forum with helpful members, and the full manual is online there as well with all functions documented.

That being said. Whats a boid?

Share this post


Link to post
Share on other sites
I think by boids he means entities controlled by a flocking algorithm. To the OP, if that is in fact what you're after, there's a good introductory article on the subject in Game Programming Gems 1. Also, a google for 'flocking AI' would probably turn up some information on the subject.

Share this post


Link to post
Share on other sites
The main SDL site has a Tutorials section and of course there is always a good old google search which can really help you out [smile] There are quite a few out there ranging from great to crap so look round if what your after isn't in the first tutorial you see.

First thing you need to decide is if your going to do a 3D version or a 2D version. With only 7 weeks its probably much safer to go for the 2D version, because you can then always create a 3D version if you have time. For a 2D boids demo all you need is to be able to draw a rotated image on screen, and move it around. Almost every tutorial will cover those topics. Once you have that then the steering behaviour comes in, and that is usually done by simply adding a few weighted vectors then scaling it. This last step takes a little fiddling to get nice weight values for each vector but its also kinda fun to see what happens.

Good luck with it!

Share this post


Link to post
Share on other sites
I'm writing a 2D AI sandbox at the moment, to try out a whole load of ideas; today I wrote my first flocking application, so I know exactly where you're coming from. Believe me, it looks mighty impressive when you get it working.

Given your time, I'd probably stick with the top-down 2d approach. All you need then is to be able to draw a circle (for the body) and a line (for the facing / orientation) for each boid - and as kaysik noted, most SDL or Allegro tutorials will tell you how to do that.

The rest, after that, is just vectors. An important piece of advice - take it step-by-step. The first thing I did today was get a flock of 15 or so stationary boids, all initialised with random location and random orientation, and then generate their sensory regions before applying the 'turn to neighbours heading' rule. So you get a bunch of circles that all end up turning towards the same direction (given a maximum turning rate - don't just snap then all to position). Then you can think about adding velocity, before building in the next 2 rules (cohesion and separation).

One of the nice things about flocking is that you can decide on the characteristics you want to have. I've played with it for hours today, just altering parameters to see how the flock behaves. If you have time, having a menu for adjusting parameters might add a lot to your demo.

If you get time, adding predator / prey rules (goody, got that to look forward to tommorow!) will add some more oompf to the demo, particularly if you can add predators interactively.

Hope this helps somewhat,
Jim.

Share this post


Link to post
Share on other sites
Cone3D has some decent tutorials for getting up and running with SDL. I wouldn't suggest writing code like that, but it works and it should give you a decent direction.

I would also stick with 2D for the time being. If you get that finished with time to spare, then maybe look at 3D. Do NOT get into 3D physics. If you can get complicated 3D physics working in 7 weeks, you should be working for Nintendo, not schlopping around in here :-)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by jyk
I think by boids he means entities controlled by a flocking algorithm. To the OP, if that is in fact what you're after, there's a good introductory article on the subject in Game Programming Gems 1. Also, a google for 'flocking AI' would probably turn up some information on the subject.



You can find the source code for implementations of boids online.

Converting to SDL and documenting/commenting it could probably be done in 7 weeks.

Share this post


Link to post
Share on other sites
Quote:
Original post by Nothingness
If you think I can't finished that in 7 weeks then what about making a program to draw 3D geometric shapes and rotate them or drop them and see the physics. Thanks for the help.

stay with flocking :)

if someone told me I had seven weeks to get a small physics engine working my first reaction would be "I'm fucked"

Share this post


Link to post
Share on other sites
I decided allegro..is that a good i dea :/.... Or should I have went with SDL? I want to start tonight atleast with something(ie. colored box or something). And by boids I did mean flocking AI.

Share this post


Link to post
Share on other sites
Quote:
Original post by Nothingness
is that a good i dea :/


Yep [cool] It really doesn't make that much difference, so stick with whatever looks best for you (good tutorial, syntax that you fit with, a colour skeme that you like). Starting is the hard thing. And if after a few days you find you don't like allegro you can always switch to SDL without too much hassle.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement