LockerGnomeTech news and nostalgia for today's technology professionals
Subscribe

Search

Software

cshoal fills a terminal with 2,000 fish and predators that hunt them

The C program borrows schooling behavior from research while documenting where its tiny ocean departs from real marine life.

Chris rests a hand on aquarium glass as a silver school of sardines swerves into a ball away from a shark.
Illustration: LockerGnome

A terminal full of fish has acquired predators. cshoal animates a school of 2,000 sardines alongside sharks, dolphins, a whale and other hunters, using the text window as its ocean. The command line finally has an appropriate place for all those shell jokes.

The project README describes each fish as following “its seven nearest neighbors.” That local relationship helps produce the visible schooling behavior instead of moving the entire group as one prearranged shape. The documentation also describes alarm spreading, turns away from predators and changes in alignment and speed.

Predators have distinct routines. Dolphins can herd the school and attack in waves. A whale approaches from below and opens its mouth near the school’s edge. The simulation replaces eaten fish from off-screen, so a long-running terminal session doesn’t have to end as a very empty aquarium.

Those behaviors are linked to research references, but the project is careful about the translation into a visual program. It lists departures from the literature, including species that don’t share a real geographic range and a reduced whale size. A lively terminal isn’t automatically a validated ecological model, however many papers appear beneath it.

Some compromises make the scene easier to watch. Predator counts are limited, and animals enter and leave from beyond the visible area. Other details are explicitly assumptions or unmeasured choices. That documentation is part of the appeal for someone curious about how a convincing animation is assembled from incomplete, simplified rules.

Building the program needs a C99 compiler and make. Display requirements include a UTF-8 terminal, a font containing Braille characters and either true color or 256-color support. A missing glyph can wreck the aquarium faster than a shark, because the marks used to draw it are part of the implementation.

The command line offers a comma-separated predator selection and a --no-predators option for watching the shoal alone. That makes a useful comparison possible without editing the source: the same schooling scene can be viewed with or without the disturbances that reveal its escape behavior.

This account uses the maker’s documentation, rather than claiming a live installation or measuring the animation’s frame rate. The source supplies the behavior descriptions and build requirements. A reader’s particular terminal and font still decide how the result appears, especially when character rendering differs across applications.

Small simulations like this can make behavioral rules approachable because the consequences are visible immediately. Watching the school split around a hunter gives the neighbor-following logic something concrete to do. The README’s limitations remain attached to the spectacle, including the imaginary gathering of species that wouldn’t meet in the same real ocean.

The terminal has a food chain.

More Software

Every Software story →