Boids Aquarium — a little society behind glass

A self-contained artificial society

A little society, behind glass.

Not another flocking demo. These boids pair up and drift apart, raise families, grow old, catch epidemics, evolve their colours and get hunted — a whole population living and dying while you watch. Open the tank and steer it. And when you've seen the society run its course, flip one switch and the same tank obeys different laws entirely: gravity.

scroll ↓

Why it's different

Most boids simulations are a swarm. This one is a society.

The classic boids model gives you cohesion, alignment and separation — three sliders and a pretty flock. Boids Aquarium keeps that graceful motion underneath, then builds an entire population biology on top: who bonds with whom, who breeds, who ages, who gets sick, whose colours win. Every number you see is a living demographic, not a physics constant.

cohesion slider alignment slider separation slider marriage & divorce Gompertz aging inbreeding depression epidemics with an R number a colour gene pool

What's alive in the tank

Six systems, one glass box

01 — society

Bonds & families

Pairs form by bumping into the right stranger, glow while fertile, raise a family, and sometimes divorce. Couples that drift too far apart stop having children, and stray far enough and they grow apart for good. Singles never settle; some boids court their own sex. Courtship even has taste — an eye for big eyes, a weakness for long beaks.

marry · breed · drift apart · divorce · widow
02 — demography

Birth, age & death

Everyone is born, matures, and ages under a real mortality curve. Seed a lone founding population and watch it climb to target — or an overcrowded one and watch it thin. A live population pyramid shows the age–sex structure, and three feedback arms quietly steer the whole thing home.

pyramid · 50/500 rule · founding growth · immigration
03 — genetics

Colour is the genome

Each boid's hue and saturation are its genes; children blend their parents' colours with the odd mutation. A preferred family sweeps the tank in an endless cycle, and a thin gene pool brings on inbreeding depression.

heredity · mutation · diversity
04 — epidemics

Disease that spreads

Infection passes by contact, trickles across pair bonds, and either kills — far more often in an inbred population — or leaves lifelong immunity. The dashboard reads out an actual R number.

contact · immunity · R factor
05 — predation

Hunger with an agenda

Predators share the boids' physics and an appetite. Set their diet to the "wrong" colour family and they become an evolutionary force, accelerating the colour cycle they feed against.

hunt · starve · shape the gene pool
06 — depth

A third dimension

Turn on depth and the flock gains a z-axis: boids swim toward you past full size and shrink into the distance, personal space turns three-dimensional, and the whole tank reads as a window instead of a wall.

2.5D · perspective · near & far

✦ The second universe

Same tank. Different laws of physics.

Press ✦ Astro in the dashboard and the society dissolves. The same bodies now obey softened Newtonian gravity with real momentum: a spinning cloud of seven hundred grains collapses, orbits, flattens itself into a tilted disk, and accretes into glowing planets — live, in the same glass box. It began as an observation that the flock's clustering looks like star formation; two missing ingredients (inertia and a long-range force) turned the resemblance into the real thing.

01 — gravity

Real orbits

Every pair attracts by softened 1/r²; bodies fall in, overshoot, and swing back. Long-lived structure lives on the virial knife-edge — so the gravity slider is adiabatic: sweep it live and orbits tighten or relax instead of shattering.

1/r² · momentum · virial balance
02 — disk formation

The pancake

Stars never flatten — their vertical wobble is forever. Gas does: it radiates energy away while rotation survives. One slider morphs the medium from star cluster to gas cloud, and the 3D blob visibly settles into a thin rotating disk, seen edge-on like an inclined galaxy.

spin · settle · stars ↔ gas
03 — accretion

Planets by collision

Touching bodies merge, conserving mass and momentum; giants grow as the cube root and gain a halo. Growth is runaway and hierarchical — grains, planetesimals, planets, a final few survivors orbiting each other — while slingshots evaporate the stragglers.

merge · ∛mass · evaporation
04 — the camera

Framing the mass

No walls out here, so the camera decides what matters: it tracks the centre of mass and frames the half-mass core, bodies sized like star markers so nothing vanishes when the view pulls out — and in the endgame it widens to keep every last survivor in shot.

half-mass framing · √zoom · endgame view

How it runs

One HTML file. A dashboard, a tank, and a kiosk export.

The whole thing is a single self-contained page — no server, no build, no dependencies to fetch. Open it and you get a control dashboard; hit a button and the aquarium opens fullscreen in its own tab, steered live from the dashboard. Or export a standalone copy: a self-running fullscreen build that works completely offline, anywhere a WebGL browser runs.

Deliveryone self-contained .html
RendererPixiJS · WebGL, embedded
Universessociety · gravity (N-body)
Dependenciesnone — runs offline
Controllive dashboard ⇄ tank
Targetany modern WebGL browser
Boidsa few hundred, at 30 fps
Bodiesteardrop, or your own images

Pull up a chair

Watch a society run its course.

Set the rules, open the glass, and see whether your population thrives, drifts inbred, or gets eaten — then flip to Astro and watch a solar system condense out of dust.

Above is a short recorded clip, looping. Press Run it live to embed the real simulation — then give it a couple of minutes: the cluster dynamics take time to unfold as groups form, drift, merge and break apart. A five-second glance won't show it. · open clip full size ↗