Falling Sand Game

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

Materials

Select a material, then paint it into the sandbox.

Selected: Sand

Brush & speed

7 cells
FineWide
1×
0.25×1×2×

Starting scenes

Loading a scene replaces everything currently in the sandbox.

Try these reactions

  • • Pour sand into water and watch density pull it through.
  • • Put oil on water, then touch the oil with fire.
  • • Drip water onto lava to make stone and steam.
  • • Build a stone cup before filling it with acid.
Advertisement

A Falling Sand Sandbox That Runs in Your Browser

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.

What It Actually Is

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.

The Materials

MaterialBehaviour
SandFalls, piles up, and sinks through lighter liquids
WaterFlows, levels out, and extinguishes fire
Stone / WallStatic and acid-proof — the material you build containers from
OilFloats on water and catches fire
FireRises, spreads to nearby fuel, then burns out
SmokeRises through lighter spaces and fades away
SteamRises, cools, and condenses under ceilings
Plant / WoodStatic, flammable, and grows where it touches water
AcidDissolves sand and plants, but not stone
LavaSlow, hot, and turns to stone on contact with water
EraserRemoves 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.

How to Play

  1. Pick a starting scene. Four are provided: an empty stone box ready to fill, a working hourglass, an elements lab pre-loaded with water, oil, acid, plants, sand and lava, or a completely blank canvas.
  2. Choose a material from the palette. Each shows a colour swatch and a one-line description of how it behaves.
  3. Draw. Click and drag, or use one finger on a touchscreen. The brush size runs from fine to wide, so you can place a single grain or fill a region.
  4. Adjust the speed if you want to watch a reaction closely — slowing the simulation makes the step-by-step nature of the rules obvious.
  5. Pause and resume to set up an arrangement precisely before letting it run, or clear the canvas and start over.
  6. Watch the readout under the canvas: frames per second, milliseconds of simulation work per frame, and how full the grid is. Fill the world completely and you will see the frame rate respond.

Reactions Worth Trying

  • Pour sand into water and watch density pull it down through the liquid rather than floating it.
  • Layer oil on water, then touch the oil with fire. The oil burns on the surface while the water below stays put.
  • Drip water onto lava to make stone and steam — then use the new stone as a wall.
  • Build a stone cup and fill it with acid. The stone holds because acid cannot dissolve it. Build the same cup from plant material and it will not last.
  • Grow plants beside water and then set the far end alight to watch fire spread along the fuel.
  • Trap steam under a stone ceiling and watch it cool and condense back to water.

Why Falling Sand Games Are Worth a Look

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.

Related Tools

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.

Frequently Asked Questions

Is it free, and do I need to install anything?

It is free, requires no download, no plugin and no account, and runs in any modern browser on desktop or mobile.

Does it work on a phone or tablet?

Yes. Drag with one finger to draw. The brush size control is useful on small screens where precise placement is harder.

What materials are included?

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.

How big is the world?

A 200 by 150 cell grid — 30,000 cells, all simulated every frame while the simulation is running.

Can I save or share what I build?

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.

Why does it slow down when the screen is full?

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.

Is this real physics?

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.

Is any of my activity sent to a server?

No. The simulation runs entirely in your browser on a canvas. Nothing is uploaded.

Things worth trying

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.

How a falling sand game actually works

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:

  1. If the cell below is empty, move into it.
  2. Otherwise, if the cell below holds something less dense, swap with it.
  3. Otherwise, try the two diagonals below.
  4. Liquids also try left and right, which is what makes them find their level.

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.

Why it stays fast

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.

Frequently Asked Questions

What materials can I use?+

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.

How do the materials interact?+

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.

Why does sand sink through water while oil floats on it?+

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.

Is this a physics engine?+

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.

Does it work on a phone or tablet?+

Yes. Drag with a finger to paint, and the canvas will not scroll the page while you are drawing on it.

Can I save what I make?+

You can download the current state as a PNG.

Is anything uploaded?+

No. The whole simulation runs in your browser and nothing is sent anywhere.

This tool is provided for informational and educational purposes only. All processing happens in your browser — no data is sent to or stored on our servers. While we strive for accuracy, we make no warranties about the completeness or reliability of results.