🌬️ Magic Sand & Smoke
Draw with the mouse to create sand, smoke, fire or water. Cellular automaton with gravity, diffusion and combustion rules in real time.
🌬️ Magic Sand & Smoke
Draw with the mouse to create sand, smoke, fire or water. A cellular automaton simulates gravity, diffusion and combustion in real time. Materials interact — water puts out fire, and flames burn out on their own.
🔬 What It Demonstrates
Each cell updates based on its neighbours: sand falls with gravity, smoke rises and diffuses, fire rises, weakens and burns out, water flows and pools.
🎮 How to Use
Select a material (sand, smoke, fire or water) and draw. Watch interactions: water next to fire puts it out and leaves a puff of smoke. Clear to restart.
💡 Did You Know?
This type of "falling sand" game was popularised by the 2005 Java applet "Hell of Sand" and inspired commercial games like Noita (2020), which builds entire worlds on pixel-level physics.
About Magic Sand & Smoke
This is a "falling-sand" sandbox built on a cellular automaton. The screen is divided into a fine grid where every cell holds a material — sand, water, smoke or fire — or is empty, and on each tick the grid is scanned and each cell follows simple local rules. Sand falls straight down and slides diagonally to pile into natural slopes, water falls and then spreads sideways to find its level, smoke rises and drifts before dissipating, and fire climbs upward, decays, burns out and randomly emits smoke. You paint materials directly with the mouse or a finger.
Cellular automata are a foundational idea in computer science and complexity theory: complex, lifelike behaviour emerges from tiny rules applied uniformly across a grid, with no central controller. The same grid-and-rules approach is used to model granular flow in hoppers and avalanches, to create smoke and fluid effects in games, and to study emergent systems like Conway's Game of Life. Each destination cell is claimed by at most one grain per step, so material is never lost or duplicated, and a falling grain cannot skip rows in one step.
Frequently Asked Questions
What is the Magic Sand & Smoke simulation?
It is an interactive falling-sand sandbox where you paint sand, water, smoke or fire and watch them flow, pile, rise and burn according to physics-inspired rules running on a grid called a cellular automaton.
What is a cellular automaton?
A cellular automaton is a grid of cells that each update their state based only on simple local rules and their neighbours. From these tiny rules, complex global patterns emerge — the principle behind this sandbox and famous systems like Conway's Game of Life.
How do I use it?
Pick a material (sand, smoke, fire or water) from the toolbar, set the brush size, then click or touch and drag on the canvas to paint. The Clear button wipes the whole grid so you can start again.
Why does the sand form natural slopes?
Each grain first tries to fall straight down; if that cell is blocked it tries to slide diagonally into an empty space below. Repeated across many grains, this produces the angled piles and slopes you see in real granular materials.
How does the water behave differently from sand?
Water also falls down, but when it cannot it spreads sideways into adjacent empty cells instead of only sliding diagonally. This lets it flow across surfaces and settle into a flat level, just like a real liquid.
Why does the smoke rise and fade?
Smoke cells move upward each tick with a little random sideways drift, because in reality hot smoke is less dense than the surrounding air. Cells also have a small chance to vanish each step and are cleared at the top, so the plume dissipates.
How does the fire work?
Fire cells rise, carry a decaying life value that eventually burns out, and randomly spawn smoke as they go. Water touching a flame extinguishes it. This produces short flickering flames topped by a trailing puff of smoke.
Why is the grid updated from the bottom up?
Scanning from the bottom upward, and flagging every cell that has already moved, ensures a grain cannot move several rows in a single step and that no two grains land in the same cell — giving stable, believable falling behaviour.
Where are falling-sand games used in the real world?
Beyond fun sandboxes, the same grid-based rules model granular flow in silos and avalanches, generate smoke and fluid effects in video games, and serve as teaching tools for emergence and complexity.
Where did falling-sand games come from?
The genre was popularised by the 2005 Java applet "Hell of Sand" and later inspired the acclaimed 2020 game Noita, in which every pixel of the world is individually simulated.
Draw with the mouse to create sand, smoke, fire or water. Cellular automaton with gravity, diffusion and combustion rules in real time.
3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install