Blog
Technology9 min readFebruary 14, 2026

How Sand Simulation Works: Cellular Automata and Falling Sand Games

Dive into the fascinating world of sand simulation algorithms, from simple cellular automata rules to complex granular physics that power modern falling sand games.

The Enduring Appeal of Falling Sand

Falling sand games have been captivating players since the early 2000s, when simple Java applets allowed users to pour virtual sand, water, and other materials onto a canvas and watch them interact. Despite their apparent simplicity, these games tap into something deeply satisfying — the ability to create, manipulate, and observe miniature worlds governed by consistent physical rules.

The appeal of falling sand simulations lies in their combination of simplicity and emergence. The rules governing each grain of sand are straightforward — fall down if there is empty space below, slide diagonally if blocked directly below, pile up when there is nowhere to go. But when millions of grains follow these simple rules simultaneously, complex and beautiful behaviors emerge: sand piles form natural angles of repose, avalanches cascade down slopes, and different materials interact in surprising ways.

Modern falling sand simulations have evolved far beyond their humble origins. Today's implementations feature dozens of different materials with unique properties, realistic fluid dynamics, chemical reactions, temperature simulation, and even biological processes. Yet the core appeal remains the same — the satisfaction of creating and observing a miniature world that behaves in physically intuitive ways.

Cellular Automata: The Foundation

At their core, most falling sand simulations are based on cellular automata — a computational model where a grid of cells evolves over time according to a set of rules based on each cell's current state and the states of its neighbors.

The simplest falling sand automaton uses a 2D grid where each cell can be either empty or contain a grain of sand. Each simulation step, the grid is scanned and each sand cell checks the cell directly below it. If the cell below is empty, the sand moves down. If the cell below is occupied, the sand checks the cells diagonally below-left and below-right. If either is empty, the sand slides in that direction (with random choice if both are available). If all three cells below are occupied, the sand stays in place.

This simple rule set produces remarkably realistic sand behavior. Sand piles up in natural-looking mounds, flows through gaps, and fills containers from the bottom up. The angle of repose — the steepest angle at which a pile of sand remains stable — emerges naturally from the diagonal sliding rule without being explicitly programmed.

Adding more materials requires extending the rule set. Water, for example, follows similar falling rules but also spreads horizontally when it cannot fall further, filling containers and finding its level. Oil floats on water by having a rule that swaps oil and water cells when oil is below water. Fire consumes flammable materials and produces smoke that rises upward. Each material adds its own rules, and the interactions between materials create the rich, emergent behavior that makes falling sand games so engaging.

Advanced Techniques

Modern falling sand simulations employ several advanced techniques to improve visual quality and physical accuracy beyond basic cellular automata.

Chunk-based updating divides the grid into rectangular chunks and tracks which chunks contain active (moving) particles. Only active chunks are updated each frame, dramatically reducing computation for large grids where most particles have settled. When a particle moves near a chunk boundary, the adjacent chunk is activated, ensuring that chain reactions propagate correctly.

Multi-threaded and GPU-accelerated simulation allows modern implementations to handle grids of millions of cells at interactive frame rates. The cellular automaton update is inherently parallelizable — each cell's new state depends only on its neighbors, so many cells can be updated simultaneously. However, care must be taken to avoid race conditions where two adjacent cells try to move to the same empty cell simultaneously.

Temperature simulation adds a layer of physical realism by tracking the temperature of each cell and modeling heat transfer between neighbors. Temperature affects material behavior — ice melts into water when heated, water evaporates into steam, metal glows red-hot, and flammable materials ignite when they reach their flash point. This thermal layer creates rich chains of cause and effect that add depth to the simulation.

Pressure simulation models the force exerted by stacked materials, enabling effects like water pressure increasing with depth, compressed gases expanding when released, and explosions propagating shockwaves through materials. Pressure adds another dimension of physical realism that makes the simulation feel more tangible and interactive.

Ready to explore?

Discover hundreds of interactive visual experiments on OddlySatisfying. From fluid simulations to particle generators, every experience is free and runs directly in your browser.

Explore Experiments →
HomeBlogAboutPrivacy PolicyTerms of Service© 2026 OddlySatisfying. All rights reserved.