I'm the creator of Cbirds, a 2D/3D bird flock simulator that runs in the terminal, written in C99 and inspired by Craig Reynolds' Boids algorithm. The video is the 3D mode running in Ghostty on macOS.
I started working on the 2D version in September 2025, mostly out of curiosity. I wanted to see whether it was possible to build a real time simulation inside a terminal using the Kitty graphics protocol.
The idea came from two places: antirez's amazing C64 terminal emulator (https://github.com/antirez/c64-kitty), and a lecture from the Foundations of AI course at Politecnico di Milano, where Professor Pier Luca Lanzi was discussing multi agent systems.
I really dislike relying on third party libraries, so I decided to implement everything from scratch in C99. I did get quite a bit of help from coding agents along the way. One interesting thing I ended up building was a custom GIF encoder, which allowed the agents to visually inspect the simulation and check whether their changes were working as intended.
The original 2D simulation is conceptually quite simple, based on the three classic rules from Craig Reynolds' work: alignment, cohesion, and separation.
In 3D each bird only listens to its nearest neighbours, seven by default as real starlings do, instead of everyone within a radius. A pull toward a roost keeps the flock in view, and a slow drift in the air over the roost does the rest: the bands, the splits and the folds in the video all come out of those rules.
From there, the project gradually grew to include:
- A full 3D simulation and renderer, running entirely in the terminal
- Real time tuning of simulation parameters
- The ability to pipe text into Cbirds and watch it fly around (e.g. `cat file.txt | cbirds`)
- Multiple flocks with different colors, with runtime controls to make them merge or avoid each other
- Hawks that chase the birds
- Different rendering techniques, ranging from PNG images displayed through the Kitty graphics protocol to Braille characters
- IPC support that lets birds fly between different terminal windows
What started as a small experiment has turned into a much bigger project than I originally expected.
Some of you may have seen the browser port posted here last week (https://nicobrenner.github.io/flock/). This is the terminal program it started from.
Source: https://github.com/clainstone/cbirds
Command in the video: `cbirds --render kitty --3d --color prism`
Install: `brew install clainstone/tap/cbirds` (also MacPorts, apt and Nix, see the README)