The left panel is the topography. Each cell carries an integer height \(h(\mathbf{x}, t)\) and the color maps taller to lighter. The right panel is D8 flow accumulation. Every cell routes its flow to its lowest 8-neighbor (steepest gradient descent), and the color counts how many upstream cells drain through each point.

At every timestep, one grain is dropped on a uniformly random active cell, then the grid relaxes. A cell \(\mathbf{x}\) is unstable when its drop to the lowest 8-neighbor exceeds the critical slope \(S_c\):

\[ h(\mathbf{x}, t) \;-\; \min_{\mathbf{y} \in \mathcal{N}_8(\mathbf{x})} h(\mathbf{y}, t) \;\;\geq\;\; S_c . \]

When an unstable cell topples, a fixed amount \(\varepsilon\) is subtracted from it and discarded from the system. There is no redistribution to neighbors:

\[ h(\mathbf{x}, t^{+}) \;=\; h(\mathbf{x}, t) \;-\; \varepsilon . \]
Topography
Flow accumulation
Grains: 0  •  Topples: 0  •  max \(h\): 0  •  mean \(h\): 0.00  •  max flow: 0  •  fps: 0
100 10 1 10000

Figure 1. Left: topography \(h(\mathbf{x}, t)\) on the composite active region (ice colormap, darker is lower). Right: D8 flow accumulation on the same stable landscape (lighter is more drainage). Slider values update live. Press space to pause, c to clear.

The interesting part is on the right panel: even though the physics is non-conservative and no material moves between cells, the stable topography still produces organized drainage networks with flow accumulation orders of magnitude above background. Toggling show contours overlays contours every 50 blocks of elevation on the largest connected region at each level, so the ridges and valleys of the landscape are visible over the colormap. The active region is a composite shape: quarter-circle (top-left), square corner (top-right), 45° diagonal cut (bottom-right), and an L-shaped notch (bottom-left). A single run exposes how each boundary type shapes the drainage pattern that emerges.