Falling Sand Playground
Paint sand, water, oil, stone, plant and fire and watch them behave. Sand heaps, water spreads, oil floats, fire burns and smoke rises.
The rules each grain follows
- Fall if you can. If not, try down-left or down-right. That second rule is the whole reason sand makes a heap instead of a tower — there is no code anywhere that knows what a heap is.
- Heavier sinks through lighter. Sand sinks through water, water sinks through oil, and oil floats to the top. One density number per material produces all of it.
- A liquid that cannot fall spreads sideways instead. Sand does not, which is the only difference between a puddle and a pile.
- Fire eats oil and plant, then becomes smoke. With nothing to eat it burns out. Water puts it out and is used up doing so. Smoke rises and fades.
- The grains are scanned from the bottom row upward. Scan the other way and a falling grain gets picked up again at its new position and drops the entire column in one frame.
- Nothing is ever created or destroyed by moving. Drop in a thousand grains of sand and a thousand are still there a thousand ticks later — there is a test that checks precisely that.
How to use
- Pick a material and drag on the canvas to paint it.
- Sand piles, water spreads, oil floats and fire spreads through anything that burns.
- Clear at any point, or add walls to build with.
Frequently asked questions
How does sand know to make a heap?
It does not — nothing in the code knows what a heap is. Each grain follows two rules: fall if you can, and if you cannot, try down-left or down-right. The heap is what happens when thousands of grains each do that. The slope angle is a consequence, not a setting.
Why does oil float and sand sink?
One number per material. A grain will swap places with a liquid below it if it is denser, so sand sinks through water, water sinks through oil, and oil ends up on top. That single rule produces all the layering you see.
What is the difference between water and sand?
One line. A liquid that cannot fall spreads sideways; sand that cannot fall simply stops. That is the whole difference between a puddle that levels out and a pile that holds its shape.
What burns?
Oil and plant. Fire spreads to anything flammable next to it, turns to smoke, and burns out when there is nothing left to eat. Water puts it out and is used up doing so. Stone never burns and never moves.
Does the sand ever disappear?
No, and it is checked rather than assumed. Moving a grain never creates or destroys one, so a thousand grains are still a thousand grains after a thousand ticks. Only fire changes what a material is.
Does it run on a phone?
Yes. It is a grid of about a hundred thousand cells stepped in the page, with nothing uploaded and no images to load. Pause it if you want the battery back.
🔒 This tool runs entirely in your browser. Nothing you enter is uploaded, logged, or stored.