TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Neat Algorithms - Flocking

220 pointsby mattkirmanabout 14 years ago

17 comments

RiderOfGiraffesabout 14 years ago
Also submitted four days ago:<p><a href="http://news.ycombinator.com/item?id=2246089" rel="nofollow">http://news.ycombinator.com/item?id=2246089</a><p>although it gains very few upvotes, and no comments. More evidence that getting noticed is largely chance, or gaming.
评论 #2263901 未加载
评论 #2264566 未加载
评论 #2264029 未加载
评论 #2264093 未加载
swannodetteabout 14 years ago
And here's a parallel version written in Clojure that scales across your cores, <a href="https://github.com/swannodette/flocking/blob/master/src/flocking/flocking3.clj" rel="nofollow">https://github.com/swannodette/flocking/blob/master/src/floc...</a>
评论 #2263666 未加载
Breefieldabout 14 years ago
If you haven't seen the boids pseudocode page by Conrad Parker it's definitely worth checking out: <a href="http://www.vergenet.net/~conrad/boids/pseudocode.html" rel="nofollow">http://www.vergenet.net/~conrad/boids/pseudocode.html</a><p>Here's an implementation I wrote last month for fun: <a href="http://breefield.com/lab/flock" rel="nofollow">http://breefield.com/lab/flock</a>. It doesn't have much bias in terms of direction (there's no wind, or patterns to follow), so there's generally one large swarm. Click-drag to create repellers, boids follow mouse. The white center of each boid shrinks at it's velocity increases, and the inverse happens to it's red direction line. Purple specks indicate perceived center of nearby flock. The rest is just aesthetic.<p>It's always super interesting to see other implementations in action, so please share more in your comments, if you have them. I'd certainly love to see them.
评论 #2264382 未加载
nihilocratabout 14 years ago
I used flocking in a game project in college (getting ad-hoc starship fleets to get into ad-hoc formations) with another condition: When the basic requirements are met, each ship should also try to align with a master "fleet admiral" ship, and the group of boids under consideration was limited to only ships specifically defined as part of the fleet.<p>It kind of worked, there were issues with stragglers and making it look organic that I couldn't fix in time. If ships got too far outside the formation sometimes they would only try aligning with the leader instead of catching up first. Also, when they did get in formation, they were eerily good at matching the leader's alignment: all ships would turn in unison and kind of ruin the organic feel of the pure flocking algorithm.
评论 #2264877 未加载
krisneuharthabout 14 years ago
See also: <a href="http://en.wikipedia.org/wiki/Swarm_behaviour" rel="nofollow">http://en.wikipedia.org/wiki/Swarm_behaviour</a><p>At a research company I worked at we used swarming concepts for controlling swarms of sensors, robots, and UAVs. We also used ant colony optimization techniques mixed with genetic algorithms to do predictive intelligence. Really powerful stuff.
mccutchenabout 14 years ago
Here's an implementation I wrote some years ago that includes obstacle avoidance. Clicking adds obstacles, spacebar adds boids, reloading gets new colors. This ended up looking somewhat like sperm avoiding eggs...<p><a href="http://humortree.org/projects/flock03/" rel="nofollow">http://humortree.org/projects/flock03/</a><p>(Java applet warning!)<p>The source code is here:<p><a href="https://github.com/mccutchen/humortree.org/tree/master/projects/flock03" rel="nofollow">https://github.com/mccutchen/humortree.org/tree/master/proje...</a>
mgunesabout 14 years ago
Very well explained. There needs to be more of this (algorithms and applied math explained in a manner somewhat accessible and nourishing to non-mathematicians through code and visualization) on the web, and I'd love to be pointed to similar resources.
joshesabout 14 years ago
Turning on the legend and the magnification of an individual boid (by clicking "Decorate") is very helpful. When you mouse over the magnified boid, you see the vectors immediately adjust, providing a very handy visual description of what is happening in real time.
评论 #2263477 未加载
kamensabout 14 years ago
I used to use boids as an interview question for candidates who whizzed through my first few code challenges -- was interesting to discuss various collision detection options with an eye on performance.<p>Such a simple algorithm w/ such a cool result.
corysamaabout 14 years ago
You may also like <a href="http://www.red3d.com/cwr/steer/" rel="nofollow">http://www.red3d.com/cwr/steer/</a>
hebejebelusabout 14 years ago
This is fantastic! Not just the algorithm, but the explanation, the fact that there's source code readily available, and the canvas demo. Please, do more!
tjarrattabout 14 years ago
I've wanted to write some exploratory algorithms for flocking for a long time now. This is just the motivation I need to start working on a silly side project.<p>Thank you, everyone in the comments who submitted source code or demos. You never know when something you upload will really brighten someone's day (even if it's written in java).
mirkulesabout 14 years ago
Cool. There's also a book called "Swarm Intelligence" by Kennedy/Eberhart that describes swarm behaviors very well (my favorite book).<p>For anyone interested, here is the Craig Reynolds page that describes the flocking behavior <a href="http://www.red3d.com/cwr/boids/" rel="nofollow">http://www.red3d.com/cwr/boids/</a>
pjvandehaarabout 14 years ago
It'd be great if someone added "[processor-heavy]" on to the title of posts like this.
thefoxabout 14 years ago
I could watch this for hours.
meatsockabout 14 years ago
glad to see you've herd of this, and are flocking to it. if you're not too flighty it's worth a peep, but you may have to duck some bugs in the code. furthermore i think flocking should be part of everyone's schooling, and there's nothing fishy about that.
VladRussianabout 14 years ago
discrete navier stokes?
评论 #2263903 未加载