Borb Cage

Borb Cage is a fidget toy: seven+ birds loose in a hanging bell cage, under a gravity you can tilt, drag, or shake. It runs as a single self-contained HTML file with no build step, no framework, and no network.

Borb Cage is a fidget toy: seven+ birds loose in a hanging bell cage, under a gravity you can tilt, drag, or shake. It runs as a single self-contained HTML file with no build step, no framework, and no network. The whole world is the state declared at the top of the file and a handful of systems that walk it.

Tap empty space and seeds drop, sometimes a berry. The birds hop over and peck when hungry; a berry excites them into a chase, and takes three bites to finish. Grab a bird and fling it; they don't mind. The bell dings when something hits it hard enough. They tire and find resting spots that suit them, and a shaken sleeper wakes grumbling. When one sings, their partner answers.

The machinery: a bird is moved by three systems that never call each other. The first turns a need into a target and a target into a shove: hungry, so head for that seed. The second is the physics: it takes the shove, adds gravity and contact and friction, and turns it into motion. The third only watches; it reads the resulting speed and picks a posture, perched or stirring or flapping, and never pushes back. The three meet only in the shared state, so any one of them can be rewritten without touching the others.

Underneath runs a fixed clock. The simulation always steps at a sixtieth of a second, banked and spent in whole ticks, so it behaves the same on a 60Hz phone and a 144Hz monitor — and exactly the same as what the tests measure. Drawing runs on the screen's own clock and interpolates between the last two ticks, so motion stays smooth at any refresh rate. The renderer only ever reads the simulation; it never writes back.

The cage builds its own map, pulled from its landmarks: the perches, the swing, the floor, the rim of the dome. Out of those it grows a set of regions and the graph between them. A bird plans a short route across that graph to get where it's going. Reshape the cage and the map re-derives; nothing about the layout is hard-coded.

The seven birds have different temperaments, each a small handful of numbers: how eager to fly, whether it drifts to the highest perch or hugs the floor, how quickly it answers another's call. On screen it reads as seven birds that each want something slightly different, which is most of what makes them feel alive.

There's no separate repository to link: the program is the page. It's a single HTML file in the portfolio's integration_08/assets/demos directory, meant to be read top to bottom.