Nice! I've done something similar in the past: http://static.mysti.co.in/boids/ Source: https://github.com/tech-no-crat/boids
https://developer.mozilla.org/en-US/docs/Web/API/window/requ...
11–20 of 31 posts
Nice! I've done something similar in the past: http://static.mysti.co.in/boids/ Source: https://github.com/tech-no-crat/boids
https://developer.mozilla.org/en-US/docs/Web/API/window/requ...
Nice! I've done something similar in the past: http://static.mysti.co.in/boids/ Source: https://github.com/tech-no-crat/boids
If you use 'requestAnimationFrame()' instead of a 'setInterval()' for triggering your update method, your animation will perform a lot smoother: https://developer.mozilla.org/en-US/docs/Web/API/window/requ...
It uses processing.js when I worked through it I just ended up implementing everything with canvas and making my own versions of the processing specific classes and functions needed.
I'm a TA for an AI-course at my uni, and this semester my students had to program a boids simulation for the first project. In addition to what's shown here, the boids also had to avoid obstacles and flee from predators. I think the students liked it, it's very rewarding to code and actually see the result.
The students also had to implement sliders, for how much cohesion, separation and alignment is weighted. It's pretty fun to change them and watch the behavior of the boids change.
I was inspired by this to create my own a few months ago. It uses a quadtree to optimize nearest neighbor lookup to ideally reduce complexity from n^2 to nlogn on each tick. http://jrhdoty.github.io/SwarmJS/
Yes, looks beautiful. Quite similar, I guess. I had run in to some performance issues, the initial few ticks are quiet slow even now, esp. on a phone. This one uses a kdtree instead. I'll have to try quadtree and benchmark. Thanks.
If what you actually want to do is to have each boid be affected by each boid in a fixed-size neighbourhood, the best acceleration structure is actually just fixed-size bins.
It also hammered home the problem of device/host memory reigions which you've got to deal with when doing GPU programming. I found that other, simpler, systems didn't manage to get as much speedup as Boids did, as transferring data, not computation, was where they bottlenecked. With Boids, by contrast, I could keep everything (computation, and rendering) on the GPU, and never even have to touch the CPU, aside from calling various CUDA and OpenCL functions.
I think almost every AI-guy have tried making a boids simulation. They are such a good way to show emergent behavior from very simple rules. I'm a TA for an AI-course at my uni, and this semester my students had to program a boids simulation for the first project. In addition to what's shown here, the boids also had to avoid obstacles and flee from predators. I think the students liked it, it's very rewarding to code…