gizmobench

Falling Sand Game

Paint sand, water and walls on a grid and watch the sand pile into slopes, the water level out and both stop at every wall you draw, a one-cell diagonal line included. Place sources that pour sand or water at the chance per step you set, run at up to 120 steps a second or step one at a time, and save scenes in this browser or as JSON. Every random choice comes from a seed, so a saved scene, left alone, carries on the same way each time you open it.

Seed 42Paused, step 0
The falling sand grid needs a browser that can draw on a canvas.

160 by 120 grid, closed edges, step 0, paused. Sand 232, water 658, wall 215, empty 18,095. 2 sources, on.

Sand
232 cells
Water
658 cells
Wall
215 cells
Step
0, paused
Brush size
Steps a second
Edges

Sources

Choose Source in the brush row, then click a cell or press Space on it to place a source there; do it again on the same cell to remove it. On each step, a source whose own cell is empty adds one cell of sand or water at the chance you set. A scene holds up to 32.

New sources pour
Sources
  • Sand sourcecolumn 41, row 5
    % a step
  • Water sourcecolumn 113, row 5
    % a step

Checks on this scene

  • A lone sand cell above a walla 40 by 30 test grid, run until it stops
    Falls 17 rows in 17 steps, one row a step, then rests on the wall and never passes through it.
  • Sources off, edges closedthis scene, 1,000 more steps on a copy
    Runs this scene on a copy with sources off and edges closed, then compares the counts.
  • Same seed, same scenetwo copies, 500 steps each from step 0
    Runs two copies of this scene from the same step and seed, then compares them cell by cell.

Scenes

Save in this browser keeps the scene under a name, up to 12 scenes. Download JSON writes a versioned file with every cell, the sources, the seed and where the random sequence has reached, so opening it here carries on from the same step. Download PNG saves the grid as an image with sharp square cells.

No scenes saved in this browser yet.

Click or drag on the grid to paint; on a touch screen, drag a finger. With a keyboard, Tab to the grid, move the cursor with the arrow keys (hold Shift to jump 10 cells), and press Space or Enter to paint with the chosen brush. Hold Space while pressing the arrows to paint a line. Painting works while the grid runs or is paused, and on a device that asks for reduced motion the example opens paused.

How it moves. Each step reads the grid from the bottom row up, left to right on even steps and right to left on odd ones. Sand falls into an empty cell or trades places with water below it, and otherwise slips one cell diagonally. Water falls, slips diagonally, or moves up to three cells sideways, stopping over a gap. Nothing squeezes between two wall cells that touch at a corner, so a one-cell diagonal line holds. Open edges let sand and water that move past them leave the grid; closed edges hold them in.
Accuracy. Stylised movement rules for creative play, not real physics or chemistry: sand falls or slips diagonally and sinks through water, water falls and spreads sideways, and walls block both. Each particle moves at most once per step and every random choice comes from the seed, so the same scene, seed and edits replay to the same grid, and with sources off, closed edges and nothing painted or erased, no cell is created or lost. There is no fire, no explosive and no reacting material.

Common questions

What is a falling sand game?
A grid of small cells, each empty or holding a material, updated in steps by simple rules that look only at nearby cells. Here the materials are sand, water and wall: on each step sand falls or slips diagonally, water falls and spreads sideways, and walls stay where you drew them. You paint the materials and watch the grid settle.
How do sand and water move in this sandbox?
Sand falls into an empty cell below it, trades places with water below it so it sinks, and otherwise slips one cell diagonally, which builds slopes. Water falls, slips diagonally, or moves up to three cells sideways, stopping over a gap so it can fall in. Nothing squeezes between two wall cells that touch at a corner, so a one-cell diagonal wall holds both. These are stylised rules for play, not real physics.
Can I play with a keyboard or on a phone?
Yes. On a touch screen, drag a finger to paint. With a keyboard, Tab to the grid, move the cursor with the arrow keys (Shift jumps 10 cells) and press Space or Enter to paint; hold Space while pressing the arrows to paint a line. Every other control is a button, field or menu you can reach with Tab.
How do sources work?
Choose Source and click a cell to place one there; click the same cell again to remove it. On each step, a source whose own cell is empty adds one cell of sand or water with the chance you set, from 1 to 100 per cent, so at 100 it pours on every step. You can change each source's material and chance, or switch all sources off at once. A scene holds up to 32 sources.
Can I save a scene and come back to it?
Save in this browser keeps up to 12 named scenes on this device, and the scene you are working on is kept when you leave the page, then reopens paused. Download JSON writes a versioned file with every cell, the sources, the seed and where the random sequence has reached, and Open JSON reads it back. Download PNG saves the grid as an image with sharp square cells.
What do closed and open edges do?
Closed edges hold everything in, as if the grid had walls around it. Open edges let any sand or water that moves past the bottom or a side leave the grid for good. With sources off, closed edges and nothing painted or erased, the number of sand, water and wall cells never changes, and the check called Sources off, edges closed runs your own scene for 1,000 steps on a copy to show it.
What does the seed do?
When sand or water could slip either way, when water could spread either way, and when a source pours at less than 100 per cent, the choice comes from a random sequence that starts at the seed. Where that sequence has reached is saved with the scene, so the same scene and seed with the same edits give the same grid, cell for cell. Change the seed, or press New seed, to see a different run from the same scene.
Is there fire, lava or acid?
No. This sandbox has sand, water and walls, with an eraser and sources to add or remove them. There is no fire, no explosive and no material that reacts with another.

Stylised movement rules for creative play, not real physics or chemistry: sand falls or slips diagonally and sinks through water, water falls and spreads sideways, and walls block both. Each particle moves at most once per step and every random choice comes from the seed, so the same scene, seed and edits replay to the same grid, and with sources off, closed edges and nothing painted or erased, no cell is created or lost. There is no fire, no explosive and no reacting material.