PDA

View Full Version : Boids Flocking Experiment AS3



Enebreus
January 8th, 2009, 08:52 PM
Just something I put together during my spare time.

This version is a little plainer but much easier to follow (I still have my debugging colours in there): http://blog.organa.ca/?p=34

This version I prettied up a bit: http://blog.organa.ca/?p=35

I'm thinking about making a game using the code. So far in the planning phases, but I'll let you guys know if I come up with something. :D

You can find the source code in the first link.

Enjoy,

Peter Organa

Iamthejuggler
January 9th, 2009, 04:15 AM
Nice, very sexy.

mlk
January 9th, 2009, 07:09 AM
Very nice, I like boids.

Are each elements aware of neighbouring elements (collision prevention with other elements ?)

edit: I hadn't read the first link

freeskier89
January 9th, 2009, 10:08 AM
You did a very nice job on this :). I really like the results in the first link because its easier to see the beauty in the behavior. My only suggestion would be to make the behavior around the edges a little less chaotic, but i don't have any brilliant ideas how to do that. Very cool though!

Edit: Wow i feel stupid lol... Now i see it reacts to the mouse. Retract my comment about the edges lol

Marije
January 11th, 2009, 08:22 PM
Very nice, I can watch it for hours!

saxx
January 11th, 2009, 08:48 PM
That's pretty cool man, how long did it take?

Enebreus
January 13th, 2009, 09:57 AM
saxx:

Not sure how many hours it took in total... 6-7ish? Maybe more... I did this at the office between paying jobs.

Keep in mind I decided to rewrite the code about half way through when I went from a trig. based approach to mostly vector math. I got a lot of help from my co-worker William who graduated with a Math degree :D He explained dot products to me. (sorta)


Recently, I've taken my source code home with me and I'm working on optimizing the code from there.

The big change I'm trying to make is adding a broad level hit detection layer to the distance detection. Right now each particle is for looping through every other particle to detect distance. I'm hoping a broad level hit detection layer will reduce the number of calculations by factor of 10 by having a particle only check it's nearest neighbours. So far I've written the code out but haven't dropped it into place yet. I may get it working this week, but it all depends on how much Left4Dead I play :P I've been playing way too much of that lately.



Peter Organa

Pasquale
January 14th, 2009, 09:51 AM
This is amazing! I'm jealous of coders!

Enebreus
January 14th, 2009, 10:12 AM
This is amazing! I'm jealous of coders!

Yeah, and I'm jealous of illustrators and designers so our karma is in balance :D

Enebreus
January 18th, 2009, 08:35 PM
Hey,

Just wanted to post an update:
I've got my boids Flock up to 2000 flockers on screen at once.

I've scaled it back to 1200 (so everyone can see it at 30fps)
You can see it here: http://blog.organa.ca/?p=36

I did this with a pretty kick *** broad level layer which speeds up the closest neighbor code by about ... err... 1000%?

Enjoy,

Peter Organa

kirupa
January 18th, 2009, 09:08 PM
Looks cool! Have you considered changing those lines to circles and submitting your entry to the FXPression contest? :P

http://www.kirupa.com/contests/index.htm

Enebreus
January 19th, 2009, 08:00 PM
Ok Kirupa I took you up on it. I've entered a modified version of my swarm code.

http://blog.organa.ca/?p=37

I'm super happy with this version. Hopefully, now I can stop making stupid modifications and go on to more important work :D

Enebreus
January 26th, 2009, 11:16 AM
Good news everyone!
My flocking code made it into the finals of the FXPression contest.

You can vote for your favourite (flocking based ;)) entry here:
http://www.kirupa.com/forum/showthread.php?t=318279

w00t!