Page 1 of 1

Pointless project #2: Boids!

Posted: Tue Nov 12, 2013 3:21 am
by Kyle
Download (0.9.0, compatible(?) with 0.8.0)

Image

I got bored so I implemented a swarming algorithm in LOVE! It's based off of Craig Reynolds's iconic Boids page. Feel free to play with it! It'd make a fantastic screensaver as well.

Re: Pointless project #2: Boids!

Posted: Tue Nov 12, 2013 4:22 am
by Kyle
Oh man, this one is fun to watch.

Download

This release adds four teams. "Swarmies" tend to follow their teammates, but they can convert to other teams if they hang out with them too much! Press C to randomize teams if things are getting boring.

Re: Pointless project #2: Boids!

Posted: Tue Nov 12, 2013 6:17 am
by micha
Good work! I like Boids.

I am still waiting for some people to come up with a game idea based on swarm behavior.

Re: Pointless project #2: Boids!

Posted: Tue Nov 12, 2013 8:05 am
by Germanunkol
I second Micha's post!

Soooooo pretty!
What's the short flash with the circle around the entities? First, I thought it was the leader, but I don't think there's any leadership involved in the algorithm...?
Edit: Ah, they change color if they're too close to other "birds"?

Re: Pointless project #2: Boids!

Posted: Tue Nov 12, 2013 7:44 pm
by Kyle
Germanunkol wrote:I second Micha's post!

Soooooo pretty!
What's the short flash with the circle around the entities? First, I thought it was the leader, but I don't think there's any leadership involved in the algorithm...?
Edit: Ah, they change color if they're too close to other "birds"?
Yep, that'd be it! They slowly convert to the team of the most prevalent one in their vicinity. It's a bit wonky sometimes though, and I'm not too sure why. I think it's time to move on to pointless project #3 now so I don't think I'll be working on it anymore. However, I do have an update that fixes their separation drive - before, it wasn't being scaled properly and frankly just did not work as intended.

Download here

Note that you can still press space to enable the pretty debugging info. The circles show their "neighbor radius", and the lines show that they are considered neighbors. The pink dot shows where each boid wants to steer towards for their "cohesion" drive - it's what keeps the flocks tight.

There are three main drivers: common direction, cohesion, and separation. Common direction just means they all try to steer towards the average direction of their neighbors (this results in it evening out into one common direction :D!). Cohesion means they try to steer towards the average POSITION of their neighbors, which keeps them bunched up. Separation is what keeps the flocks from collapsing into a single blob - they all try to maintain a certain distance from each other. I was going to make up a nice little UI for adjusting each value, but it'd take too long. If you want to play with it, most of the values are at the top of main.lua. Have fun! It's endlessly entertaining, IMO.