A random walk takes a step in a random direction every frame. Change the probability distribution behind that step and the walker’s character changes completely: uniform steps jitter in place, Gaussian steps drift, and Lévy flights make long jumps the way foraging animals do. Perlin noise gives smooth randomness, where each value is close to the last — the secret behind natural-looking terrain, clouds and motion.
Monte Carlo methods use randomness to compute things: throw enough random points at a square and you can estimate π.
Every simulation below runs right here in your browser, for free, with live controls. Open one, change the sliders, and use the mouse — most of them respond to it.
Randomness simulations
Random Walkers

A random walk is the simplest model of motion: every frame the walker takes a step chosen by chance. Changing the probability distribution of that step changes the character of the path completely.
Try this: Pick "Biased toward mouse", then move the cursor around and watch the walkers follow you.
Distributions

Gather thousands of random numbers into a histogram and the shape of their distribution appears.
Perlin Noise Landscapes

Perlin noise gives a smooth sequence of pseudo-random values: nearby inputs give nearby outputs. Sampling it in 2D makes cloud-like textures, and in 3D you can animate those textures over time.
Layering octaves (copies at double the frequency and lower amplitude, controlled by falloff) adds fine detail on top of the broad shapes. This is fractal noise.
Try this: Switch to 1D graph to compare raw Math.random() with noise side by side, then raise the octaves.
Open Perlin Noise Landscapes →
Self-Avoiding Walk

A random walker on a grid with one extra rule: it may never visit the same spot twice. That small constraint changes the statistics completely. Self-avoiding walks are used to model polymer chains, which cannot pass through themselves.
Sooner or later the walker traps itself. It can then restart, or backtrack along its path to the last spot that still had a free neighbour. Backtracking is depth-first search, and it eventually fills the whole grid, carving a random maze (the faint lines).
Try this: Switch to "Restart" and watch how short the walks usually are before they get stuck.
Monte Carlo π

Randomness can compute things. Throw darts uniformly at a square that contains a circle. The fraction that lands inside approaches the ratio of the areas, π/4, so π ≈ 4 × inside / total.
This is a Monte Carlo method. The error shrinks only like 1/√n: 100× more darts buy one extra correct digit. The chart shows the estimate wobbling toward π.
Try this: Set the darts per frame to 1 and watch how noisy the first estimates are.
Flying Over Noise Terrain

2D Perlin noise read as a height map becomes a landscape. Each grid point's height is noise(x, z), and the grid is drawn in perspective: screen position = world position × focal length ÷ depth.
To fly, we slide the noise sampling window forward each frame instead of moving a camera. Quads are painted far-to-near (the painter's algorithm), so near hills hide far ones.
Try this: Try "Ridge lines" with 1 octave, then raise the octaves and watch the detail appear.
Open Flying Over Noise Terrain →
Brownian Motion & Diffusion

Release thousands of random walkers from one point and the cloud diffuses. No walker is going anywhere, yet the cloud grows, and it grows in a precise way. The typical (root-mean-square) distance from the start rises with the square root of time: r ≈ s·√(2t).
Einstein used exactly this relation in 1905 to explain the jittering of pollen grains (Brownian motion) and to prove that atoms exist. The solid ring is the measured RMS distance; the dashed ring is the theory.
Try this: Watch the chart: doubling the distance takes four times as long.
Open Brownian Motion & Diffusion →
Paint Your Own Distribution

The accept–reject method can sample any shape you like. Draw a curve in the top panel with the mouse. That curve is a probability density. Each sample picks a random x and a random height, and keeps x only if the height falls under your curve.
The histogram below slowly reproduces your drawing. The white outline shows the shape it should converge to. Rejected samples are wasted work, which is why spiky curves sample more slowly.
Try this: Draw two separate humps for a bimodal distribution, then watch the acceptance rate.
Open Paint Your Own Distribution →
Domain-Warped Noise

Noise can bend other noise. Instead of sampling noise(p), sample noise(p + 4·noise(p + 4·noise(p))): the coordinates themselves are pushed around by noise before being read. This domain warping turns plain clouds into swirling marble, smoke and flowing paint.
The colours mix according to the intermediate warp values, so you can see the layers of distortion. The same trick is used for procedural textures in film and games.
Try this: Set the warp strength to 0 to see the plain noise, then slowly increase it.
Maze Generation & Solving

The backtracking self-avoiding walk carves a perfect maze: every cell is reachable and there is exactly one path between any two cells. Here that random depth-first walk knocks down walls as it goes.
Then a solver searches from the top-left to the bottom-right. Breadth-first search floods outward evenly and is guaranteed to find the shortest path. A* adds a heuristic (distance to the goal) to explore the most promising cells first, usually visiting far fewer.
Try this: Solve the same maze twice: once with breadth-first, once with A*. Compare "cells explored".
Open Maze Generation & Solving →
Buffon's Needle

Another way to find π by chance, first posed in 1777. Drop needles of length l onto a floor of parallel lines spaced d apart. The probability that a needle crosses a line is 2l / (π·d), so counting crossings gives π ≈ 2·l·N / (d·hits).
The circle never appears, yet π shows up because every needle angle is equally likely, and averaging over all angles means averaging a sine.
Try this: Change the needle-to-gap ratio. The estimate still converges to π, but the speed of convergence changes.
Procedural Noise Planet

Wrap noise around a sphere and you get a world. For each pixel of the disc we work out the 3D point on the sphere's surface, rotate it, and sample 3D Perlin noise there. Sampling in 3D avoids the seams and pinched poles you get when wrapping a flat 2D map.
Height decides ocean, beach, forest, rock or snow. Latitude adds polar ice. A dot product between the surface normal and the light direction gives day and night shading, the same vector math as in Chapter 1.
Try this: Press "New world" a few times, then lower the sea level to raise the continents.
Open Procedural Noise Planet →
Evolve them into something new
Several of these are already evolutions: Self-Avoiding Walk grew out of Random Walkers; Monte Carlo π grew out of Distributions; Flying Over Noise Terrain grew out of Perlin Noise Landscapes; Brownian Motion & Diffusion grew out of Random Walkers. In Labs you can take any of them a generation further: press Evolve this, get suggestions for what the next version could add, and build the one you like — or combine two or three simulations into one system.
Make your own simulation →
Pick randomness as a concept, choose an art piece, game, explainer or experiment, and Labs suggests ideas and builds the one you choose.