gekro
GitHub LinkedIn

Falling Sand

Play with a sandbox of falling sand, water, oil, fire, steam and plants, draw with your finger or the keyboard, and find six small discoveries.

Particles 0

Discoveries 0 of 6

Things to discover

  • Sand sinks in water and oil, not found yet
  • Oil floats on water, not found yet
  • Plants drink water and grow, not found yet
  • Fire burns wood, plants and oil, not found yet
  • Fire boils water into steam, not found yet
  • Steam turns back into water, not found yet

Draw with a mouse, finger or pen; hold still to keep pouring. With the keyboard, Tab to the sand box, then arrow keys move the square cursor (Shift moves 5 at a time) and Space or Enter pours. On the box: 1 to 8 pick sand, water, stone, wood, fire, steam, plant, oil; 9 or X is the eraser; [ and ] change the brush; P plays or pauses. Nothing moves until you draw or press Play.

How the rules work
  • Sand falls straight down, or slides down to the left or right. It sinks through water and oil.
  • Water falls, slides down to the side, and spreads sideways. It sinks under oil.
  • Oil moves like water, so it floats on top of water. Fire sets it alight quickly.
  • Stone and wood never move. Wood burns slowly.
  • Fire lasts a short while and may flicker upward. Every moment it can light wood, plants or oil beside it. Beside water it turns into steam.
  • Steam rises and drifts. After a few seconds it cools and falls as water again.
  • A plant is still. Now and then it drinks one touching drop of water and grows into that spot.
  • Particles never leave the box, and sand, water and oil are never created or lost by moving.

Every step the grid is walked from the bottom row up, so a falling grain moves once and not twice. Each cell is tracked with a small step stamp, and only the cells that changed are redrawn.

As-is, no warranty. These apps are free under their listed license and run entirely in your browser. Use at your own risk — don't blame me if your PC catches fire, your dog runs away, or the math turns out wrong. Verify anything that actually matters. None of this is professional financial, medical, legal, or engineering advice.

© 2026 Rohit Burani · MIT · Built at gekro.com · View source ↗

Guide

How to play

Pick a material, then draw on the sandbox with a mouse, a finger or a pen. Hold still to keep pouring while the sandbox is playing. Nothing moves until you draw or press Play, so the starting scene (a stone bowl of water with plants, a pile of sand, a wooden tower and some oil on a shelf) waits for you.

MaterialWhat it does
SandFalls, slides down slopes, and sinks through water and oil.
WaterFalls, slides and spreads sideways. It sinks under oil.
OilMoves like water, so it floats on top of water. Fire lights it quickly.
StoneNever moves. Good for walls, bowls and shelves.
WoodNever moves, but fire can burn it.
FireBurns for a short while and may flicker upward. It lights wood, plants and oil beside it. Next to water it turns into steam.
SteamRises and drifts, then after a few seconds cools and falls as water again.
PlantStays put. Now and then it drinks one touching drop of water and grows into that spot.
EraserClears whatever you draw over.

Sand, water, oil and steam come out in a sprinkle, about six squares in ten, so pouring looks like pouring. Stone, wood and plants fill every empty square under the brush. Fire fills empty squares and sets light to wood, plants or oil under the brush. Nothing you draw replaces a particle that is already there, except the eraser, and fire lighting what can burn.

Buttons. Play and Pause start and stop the sandbox. Clear empties it. Restart brings back the starting scene. Small, Medium and Large brush set the size of the circle you draw with.

Six things to discover. A list beside the sandbox ticks off what you have found: sand sinks in water and oil, oil floats on water, plants drink water and grow, fire burns wood, plants and oil, fire boils water into steam, and steam turns back into water. Each one is announced when it first happens, and the page remembers which you have found.

Keyboard. Press Tab until the sandbox is selected. A round cursor appears, sized like your brush. Arrow keys move it (Shift moves five squares at a time) and Space or Enter pours, and holding the key keeps pouring. Keys 1 to 8 pick sand, water, stone, wood, fire, steam, plant and oil. 9 or X is the eraser, [ and ] change the brush size and P plays or pauses. A status line says what each action did.

How it works

The sandbox is two lists of numbers, one entry per square: which material it holds, and a life counter for fire and steam. A tick walks the squares from the bottom row up, alternating left-to-right and right-to-left each tick so nothing drifts to one side. Each square gets a stamp with the tick number whenever it changes, and a square stamped this tick is skipped, so a grain of sand falls exactly one square per tick and never twice. The tests drop a grain down a tall empty column and check it moves one square at a time.

The rules, with the chances the tests use:

  • Fire lights a touching wood square 8 times in 100 each tick, a plant 20 in 100, oil 35 in 100. A fire lit from wood lasts 40 to 89 ticks, from a plant 8 to 19, from oil 6 to 15, and fire you paint lasts 10 to 33. Beside water, fire becomes steam at once. It rises into an empty square above about 3 ticks in 10.
  • Steam rises 85 times in 100 when the square above is empty, drifts when it cannot, and lasts 90 to 159 ticks before it becomes water again.
  • A plant checks for touching water on 5 ticks in 100, and when it finds some it turns that water square into plant.

Every rule pair is checked in a table of tiny boards, each with a fixed random source so the outcome is exact: sand over water swaps, water over oil swaps, oil over water stays, sand in a one-wide well stays, water in a one-wide well stays, fire beside water makes steam, fire lights wood on a low roll and leaves it on a high roll, a plant drinks on a low roll and not on a high one, and stone and wood never move.

Sand, water, oil and stone are never created or lost by moving. The tests fill a 24 x 24 box at random and run 3,000 ticks, then check that each of those counts is exactly what it was. In a second run with fire, steam, plants and wood all in play, they compare the running count of every material with a fresh recount every 20 ticks for 800 ticks. The same seed always gives the same sand.

Speed. The sandbox runs 30 steps a second, or 15 if you have asked your device for reduced motion. When the sandbox is narrower than 520 pixels, as on a phone, the grid is 120 x 90 instead of 160 x 120, so there are fewer squares to work through. Only squares that changed are rewritten before each frame is drawn, the canvas is sized to its box times the device pixel ratio (never more than 2), and the loop stops when the tab is hidden.

Colours. Each material has eight shades, picked by square position so a pile looks grainy. They are mixed from the site’s four accent colours. Fire is picked by how much life it has left, so a flame deepens from amber through orange to rose as it dies, instead of blinking.

Privacy and limits

Nothing is uploaded. The only thing stored is which discoveries you have made, as one whole number from 0 to 63 in local storage. The picture itself is not saved.

  • The sandbox is a simplified model. Water does not push, pressure does not exist, and fire never uses up oxygen.
  • Steam that reaches the top stays there until it cools.
  • Plants can only grow by drinking, so they do not spread across dry ground.
  • A long-running sandbox may reach a still state. Press Restart for the starting scene or Clear for an empty box.
All Fun tools →

For informational purposes only. Not financial, medical, or legal advice. You are solely responsible for how you use these tools.