It’s a grab-bag of the classics: boids flocking, an N-body gravity dance, Conway’s Game of Life, reaction-diffusion, a double pendulum chaos fan-out, Lotka-Volterra, L-system plants, Voronoi, plus some agent-based ones (boids vs predator, and a genetic algo that evolves little navigators through an obstacle field). Every demo has live sliders so you can poke at it, pause, and watch things fall apart in real time.
Would love to hear what you think, and totally open to demo ideas if there’s something fun you want to see thrown in.
The Navigation Evolution one is probably my favorite.
This is AMAZING! I haven’t seen anything using genetic algorithms in years, which was a topic for my PhD (never finished it :D). I need to spend some time with your source to see what you did there, so cool.
Let me know if you have any questions I tried to make the underlying methods really generic so they can be reused wherever. I’m excited someone appreciates it! All the code should have some inline comments to the scientific methods employed!
I spent last time tonight with it, love how you encoded the agent in the chromosomes, super clever. And the stamina concept to limit params from growing is a great idea!
Yeah I tried to make a “tripartite” relationship between basic factors:
Speed/Agility
Environmental Awareness
Endurance/Stamina
Basically the Stamina is the base pool that the entity has to burn up before they “die”. This is drained by their max speed and acceleration values along with being drained for the energy they invested into their environmental awareness (arc of vision and how many rays they cast). Then you have Endurance to kind of balance everything out, its basically the factor how how much the entities movement gets hindered by the draining of their stamina. At a 1 they get no change in speed as they get tired, but at a 0.1 endurance by the time they hit 0 stamina they are moving at 10% of their max speed, accel and turn.
That way there is a balancing act happening in their evolution. Depending on the layout of the obstacles you will see different divergent traits take the lead role as the most fit. I should probably add more data graphs to this.
Glad you liked it!
Im about to post later tonight my GPU version of the boids simulation, you can do hundreds of thousands of boids instead of a couple thousand.
Just deployed the new Boids demo during my lunch break. You have a toggle to switch between CPU and GPU mode on the fly and should see really no disruption (but a flicker) in the simulation
There is still a readback to the CPU in this version so about 45k is the upper limit till you hit the buffer bottle neck, but Im looking to do a GPU only rendering version which will allow for counts upwards of +200k
There is something up between the deployed version and my local one… interesting, Ill have to dig in but the deployed one is being kinda buggy and not showing the correct amount of GPU boids. I dont have time to look at it right now because real work calls, but ill check out whats the problem later.
UPDATE
I had Claude take a look at what I was doing and was able to get back to the version that does no buffer readback and now we can run ~200k on the GPU with collisions now as well! The deployment for that fix should land soon.
So I’ve been on a tear. What started as a couple of experiments turned into a whole arcade of live simulations
Most demos have a CPU/GPU toggle. Flip it and watch the same simulation jump from “a few thousand” to “why is my fan spinning.” All the GPU paths are real WebGPU compute shaders — no fake instancing tricks.
Pressure Blobs — squishy jelly soft-bodies with actual ideal-gas pressure holding them up. They collide with each other, squish into foam-like cells, and you can grab and fling them around with the pointer.
Cloth (XPBD) — mass-spring cloth with structural + shear + bend constraints, draped over a sphere collider that you can move around.
Verlet Rope — position-based chains. On GPU it’s thousands of ropes whipping in the wind.
SPH Fluid — position-based fluids with a 3D spatial hash. It actually holds a pool and sloshes like a fluid should instead of collapsing into a puddle.
Slime Mold — Physarum agents that sense, rotate, and move, leaving a glowing trail field that self-organizes into transport networks. 200k agents on the GPU, rendered straight to a texture.
IK Chain (FABRIK) — forward-and-backward reaching inverse kinematics chasing animated targets. 2k chains at once on GPU, bones and all.
Kelp Forest — buoyant leaf-ribbon kelp swaying in a layered current
Go break something and tell me what you’d want to see next.
Love the demos! I noticed that the soft blobs for some reason on GPU mode are very slow in my computer. And the fluid looks different in CPU and GPU too.