? ? Physics & Mechanics

?? Sandbox

Particles: 0
FPS:

⏳ Sandbox — Cellular Automaton

Draw with sand, water, fire, wood, acid and smoke — watch substances interact with physics and chemistry rules. Fire ignites wood, acid dissolves materials, water pools at the bottom.

🔬 What It Demonstrates

Each pixel is a cell that follows rules: sand falls with gravity and piles at the angle of repose, water flows and fills cavities, fire uses cellular combustion rules.

🎮 How to Use

Select a substance and draw with the mouse. Combine materials to see reactions: fire + wood = smoke, acid dissolves most materials, water extinguishes fire.

💡 Did You Know?

This "falling sand" genre traces back to 1986's Tetris-inspired experiments and the 2005 classic "Powder Game". Modern games like Noita (2020) push pixel physics to extraordinary complexity.

About the Falling-Sand Cellular Automaton

This sandbox is a two-dimensional cellular automaton in which the screen is divided into a grid of small cells, each holding one material: sand, water, lava, stone, plant, gas, or the steam and fire that reactions produce. Every cell obeys a few simple local rules, expressed as next(x,y) = rule(state, neighbours). From these trivial rules complex, lifelike granular and fluid behaviour emerges across the whole grid.

The grid is scanned from the bottom row upward, with the column order shuffled each step to remove directional bias. Sand falls and slides diagonally to its angle of repose, water flows down then spreads sideways, gas and steam rise, and neighbours react: lava meeting water becomes stone and steam, while lava or fire ignites plant. Such models underpin granular-flow research, geology, and games like Powder Game and Noita.

Frequently Asked Questions

What is a falling-sand simulation?

It is a cellular automaton where the canvas is a grid of cells, each storing one material type. Each cell follows simple local rules every frame, and the collective result looks like sand, water and fire behaving physically. It is a sandbox toy, not a precise fluid solver.

How does the simulation actually work?

On every physics step the grid is scanned from the bottom row up. Each non-empty, non-stone cell tries to move according to its material rule, and reactions between neighbouring cells are checked. The new state of any cell depends only on itself and its immediate neighbours.

What do the controls do?

The material buttons select what you paint: Sand, Water, Lava, Stone, Plant, Gas or Erase. Brush size sets the radius of the circular area painted, from 1 to 20 cells. Speed sets how many physics steps run per rendered frame, from 1 to 8. Clear empties the entire grid.

Why is the column update order shuffled each step?

Scanning columns left to right would bias movement toward one side, so sand and water would drift in a preferred direction. Shuffling the column order every step averages this out, giving symmetric, more natural-looking piles and flows.

How does sand reach its angle of repose?

A sand cell first tries to fall straight down into an empty cell or to displace water below it. If blocked, it attempts to slide diagonally into an empty cell below-left or below-right. This diagonal sliding is what builds the characteristic sloped pile rather than a vertical stack.

What reactions can occur between materials?

Lava falling onto water turns the water to stone and leaves steam behind. Lava and fire can ignite neighbouring plant cells, which then burn as fire. Fire spreads to adjacent plant, burns out into gas, and gas slowly dissipates. Plant can also spread slowly where it touches water.

Does water behave like real fluid?

Only loosely. Water falls when there is empty space below, otherwise it tries to spread sideways up to three cells. This produces convincing pooling and levelling, but it ignores pressure, viscosity and incompressibility, so it is a qualitative approximation rather than a Navier-Stokes fluid solver.

Is the simulation physically accurate?

It captures the qualitative essence of granular and fluid motion: gravity, piling, flowing and simple phase reactions. It is not quantitatively accurate, because cells move at most one step per frame on a coarse grid using probabilistic rules, with no real forces, momentum or units.

What does the Speed control change?

Speed sets how many physics steps are computed for each frame the browser draws. At a value of 1 the simulation advances one step per frame; at 8 it advances eight, so materials settle and react much faster, at the cost of more computation per frame.

Why are stone and empty cells skipped during updates?

Empty cells have nothing to move, and stone is treated as a static solid that does not fall or react. Skipping both keeps the per-frame loop fast, so the simulation can run thousands of active cells smoothly while still checking every potentially moving particle.

How is this related to Conway's Game of Life?

Both are cellular automata whose global behaviour emerges from simple rules applied to each cell based on its neighbours. The Game of Life, devised in 1970, popularised the idea that trivial local rules can create rich patterns; falling-sand toys apply the same principle to granular and fluid materials.