Play a falling sand game in your browser. Draw sand, water, oil, fire, lava, acid and plants on a 200x150 grid and watch cellular automaton rules play out.
Sandbox
Sand · 7-cell brush
Drag or draw with one finger. Pick two materials and make them meet.
— FPS · 0.00 ms · 4% full
Select a material, then paint it into the sandbox.
Selected: Sand
Loading a scene replaces everything currently in the sandbox.
Pick a material, drag on the canvas, and watch what happens. Sand piles up and slides down slopes. Water finds its level and puts out fire. Oil floats on water and burns. Lava meeting water turns to stone and throws off steam. Acid eats through sand and plants but not stone. There is no score, no goal and no timer — it is a toy, and the fun is in setting up situations and seeing how the rules resolve them.
It runs entirely in your browser with nothing to install, no account and no data leaving your device. It works with a mouse or a finger, so it is as usable on a phone as on a desktop.
Under the surface this is a cellular automaton. The world is a grid — 200 cells wide by 150 tall — where each cell holds one material or nothing. Every frame, the simulation visits the cells and applies a short list of local rules: a rule only looks at a cell and its immediate neighbours, and nothing has a plan, a path or a physics engine behind it. There are no forces, no velocities and no collision detection.
What makes it interesting is that the behaviour you recognise as “sand” is not programmed anywhere. Sand does roughly this: if the cell below me is empty, move down; otherwise if a diagonal below is empty, move there; otherwise stay put. That is all. Slopes, piles at a consistent angle, and the way a pile collapses when you remove its base all emerge from those three lines applied a few thousand times per frame. The same is true of everything else: water is sand that also moves sideways, which is enough to make it level out and flow around obstacles.
| Material | Behaviour |
|---|---|
| Sand | Falls, piles up, and sinks through lighter liquids |
| Water | Flows, levels out, and extinguishes fire |
| Stone / Wall | Static and acid-proof — the material you build containers from |
| Oil | Floats on water and catches fire |
| Fire | Rises, spreads to nearby fuel, then burns out |
| Smoke | Rises through lighter spaces and fades away |
| Steam | Rises, cools, and condenses under ceilings |
| Plant / Wood | Static, flammable, and grows where it touches water |
| Acid | Dissolves sand and plants, but not stone |
| Lava | Slow, hot, and turns to stone on contact with water |
| Eraser | Removes whatever the brush passes over |
Density is what drives most of the interactions. Sand is denser than water, so it sinks through it. Oil is less dense, so it rises to sit on top. Gases rise for the same reason in reverse. Once you know each material’s density and whether it is flammable, you can predict almost everything the simulation will do.
Falling sand games have been around since the early 2000s, and they endure because they are the most approachable demonstration of emergence there is. Nobody wrote code that says “make a pile at a 30-degree angle” or “let water flow around this obstacle”. Those behaviours fall out of trivially simple per-cell rules applied uniformly across a grid, and watching that happen teaches something about complex systems that a written explanation does not.
The same idea — a grid, a neighbourhood, a rule, and time — is behind Conway’s Game of Life, fluid and traffic modelling, image-processing kernels, and procedural terrain generation. This is a friendlier entry point than any of them because the output looks like something you already have intuitions about.
There is also a practical engineering lesson visible in the FPS readout. Updating 30,000 cells every frame in a browser at an interactive frame rate is not free. Watch what happens to the milliseconds-per-frame figure as the grid fills up: cost tracks the number of active cells, which is why real simulations of this kind work hard to skip regions where nothing is moving.
If the cellular automaton idea is what caught your interest, the Game of Life simulator is the canonical version — two rules, one cell state, and startlingly complex results. For a different kind of grid-based browser toy, the colour picker and the rest of our developer tools are worth a look.
It is free, requires no download, no plugin and no account, and runs in any modern browser on desktop or mobile.
Yes. Drag with one finger to draw. The brush size control is useful on small screens where precise placement is harder.
Sand, water, stone, oil, fire, smoke, steam, plant/wood, acid and lava, plus an eraser. Each one has a short description of its behaviour next to its swatch in the palette.
A 200 by 150 cell grid — 30,000 cells, all simulated every frame while the simulation is running.
No. The state lives in the page while you have it open. It is designed for quick experiments rather than persistent creations — the four starting scenes are there so you can get back to an interesting arrangement fast.
Every occupied cell has to be evaluated each frame, so the work scales with how much material exists. The readout shows the current frame rate, the milliseconds spent simulating, and how full the grid is, which makes the relationship easy to see.
No. It is a cellular automaton, not a physics engine — there are no forces, velocities or collisions, only simple rules about what each cell does relative to its neighbours. The convincing behaviour is emergent, which is the interesting part.
No. The simulation runs entirely in your browser on a canvas. Nothing is uploaded.
Build a container first. Draw a bowl out of stone, then pour water into it. Stone is the only material that never moves and the only one acid cannot eat, so it is what everything else gets tested against.
Layer oil on water. Pour water into a container, then oil on top. The oil settles above the water because it is less dense. Now drop a single spark of fire on it.
Drop lava into water. Each contact turns the lava to stone and the water to steam. Pour lava slowly into a full container and you can build a stone plug that stops the rest getting through.
Feed a plant. Plants creep along wet cells, so a plant next to water spreads. Let it dry out and set it alight to watch fire follow the growth.
Pour acid on a sand pile inside a stone box. The sand disappears and the box survives, which is the difference the rules draw between the two.
There is no physics engine here. The world is a grid of integers and one short rule per material, applied to every cell each frame:
Everything people recognise as sand behaviour - pouring, piling at an angle, settling - comes out of those four lines rather than being modelled.
Two details do most of the work. The grid is scanned bottom-up, because scanning downward would let a single grain fall the whole height in one frame as the loop kept catching up with it. And the scan direction alternates each row, since always sweeping the same way biases which diagonal wins and makes piles lean visibly to one side.
Drawing thirty thousand cells as individual rectangles would be far too slow to hit sixty frames a second. Instead the grid is written straight into an ImageData buffer at one pixel per cell, and that small image is scaled up to the canvas with smoothing switched off, which gives the crisp pixel look as a side effect.
Colours come from a table computed once at startup, so no colour strings are built inside the frame loop.
Measured on the full 200 by 150 grid with around seventeen thousand cells occupied, a simulation step takes about a third of a millisecond - roughly a twentieth of the budget available at sixty frames a second, leaving the rest for rendering and interaction.
Sand, water, stone, oil, fire, smoke, steam, plant, acid and lava. Stone is the inert one - use it to build containers that hold everything else.
Water puts out fire and turns to steam near lava. Lava sets fire to anything flammable and hardens into stone when water touches it. Oil floats on water and catches fire readily. Acid eats through most things but not stone. Plants grow along wet cells and burn well once dry.
Because each material has a density and a cell swaps with the one below it when that one is lighter. Sand is denser than water so it sinks; oil is lighter so it rises. Neither behaviour is special-cased - both fall out of the same rule.
No, and that is what makes it fast. There are no particles with velocities, just a grid of cells and a short list of rules applied to each one every frame. Pouring, piling and flowing are emergent from those rules rather than simulated directly.
Yes. Drag with a finger to paint, and the canvas will not scroll the page while you are drawing on it.
You can download the current state as a PNG.
No. The whole simulation runs in your browser and nothing is sent anywhere.