Start with a random point. Repeatedly: pick a random vertex, move r of the way toward it, plot the result. Remarkably, this random process deterministically produces the Sierpiński triangle.
This is an Iterated Function System (IFS) — a set of contractive affine maps whose unique fixed point (the attractor) is the fractal. For the triangle, the three maps are:
The Hausdorff dimension of the Sierpiński triangle is:
This follows from the Moran equation: if 3 copies each scaled by r=1/2, then N·r^d = 1 → d = log(3)/log(2). Try different vertex counts and ratios to discover other fractal attractors!