Skip to main content
← All work

sandlife

A falling-sand sandbox in C where sand, water, plants and fire form little ecosystems that live, oscillate, or collapse.

Status

Working, with an interactive mode and headless modes that benchmark and dump a snapshot.

Language
C
Elements
8
Throughput
940 Mcell-updates/s
Lines
1,862
Commits
11

Fast enough to search

It is a sandbox you can paint into, but the reason it is written the way it is — flat data, no cleverness, a benchmark mode built in from the start — is that the eventual target is a search over element rules for ecosystems that sustain themselves indefinitely.

A search like that is only worth starting if one simulation step is cheap, so the step is where the work went: a SIMD path, a hand-written assembly kernel, and threads over the grid. Measured, that is 940 million cell updates a second on this laptop.

The headless modes exist for the same reason. One reports timing and a census of what is still alive; the other dumps a snapshot after a fixed number of steps, so two rule sets can be compared without a person sitting and watching them.