Every dancer picks one friend and one enemy. At each step the dancer shrinks a little toward the middle of the floor, takes a big step toward the friend and a small step away from the enemy. Now and then it changes its mind and picks again.
The rule is from a 2012 post by Simon Woods on Wolfram Community. I ported it to WebGPU and scaled it from thousands of dancers to millions.
The rule has no neighbourhood. Woods found that searching for the nearest neighbours was too slow, so each particle reacts to two others, wherever they are. The look of the swarm comes from that one choice.
What I did#
The simulation, the point drawing and the glow all run on the GPU. The page is plain ES modules, about 2,100 lines of JavaScript, with no dependencies.
You can set the number of dancers (10,000 to 4 million), who picks whom (random, rings, cliques, local), 2D or 3D, step sizes, colours and trails. The pointer pushes dancers around. The whole state goes into the URL, so a link shares exactly what you see.
In my benchmark with 4 million dancers the median was about 124 frames per second.
It needs a browser with WebGPU: Chrome or Edge 113 and later, Safari 26, Firefox 141.