Chaos Game (Sierpiński)

The chaos game is a probabilistic construction of fractal sets using iterated function systems (IFS). Fix three non-collinear vertices of a triangle in the plane. Start from any point inside the triangle (here, the centroid). At each step, choose one vertex uniformly at random and replace the current point by the midpoint between the current point and that vertex. Repeating this affine “halfway toward a vertex” map generates a cloud of points whose closure is the Sierpiński triangle (Sierpiński gasket): a compact fractal of Hausdorff dimension log 3 / log 2 in the ideal limit. Coloring each plotted pixel by the index of the vertex chosen on that step reveals how the attractor partitions into three self-similar copies, each associated with one vertex. The simulator rasterizes the process on a pixel buffer with adjustable ink strength and iteration rate; the outline shows the generating triangle. This is a standard classroom bridge from random processes to deterministic fractal geometry, complementary to algebraic IFS descriptions {f_k(x) = (x + V_k)/2}.

Who it's for: High school through early undergraduate learners exploring fractals, probability, and iterative constructions; anyone comparing Monte Carlo style processes to geometric self-similarity.

Key terms

  • Chaos game
  • Sierpiński triangle
  • Iterated function system (IFS)
  • Affine map
  • Attractor
  • Self-similarity
  • Fractal dimension
  • Midpoint iteration

How it works

Randomized chaos game on a triangle: each step pick a random vertex and move the current point halfway toward it. The long-run cloud fills the Sierpiński triangle (an IFS attractor). Coloring by the chosen vertex shows how the gasket splits into three self-similar pieces.

Key equations

P ← (P + V_k) / 2 , k ∈ {0,1,2} uniform

Frequently asked questions

Why does a purely random rule produce a deterministic shape?
The randomness only chooses which contraction map to apply; each map is a strict contraction of the plane toward a vertex. Almost every infinite sequence of choices visits the attractor densely, so the empirical point cloud reveals the unique nonempty compact invariant set of the three-map IFS—not a fuzzy blob.
Do I need the starting point inside the triangle?
Any starting point in the plane converges visually into the gasket after discarding an initial transient, but points far away take longer to “fold in.” Starting at the centroid avoids an obvious early streak.
What changes if I turn off “color by vertex”?
The same attractor appears, but without the three-way coloring that highlights which map was most recently applied. Monochrome mode emphasizes overall density; color mode emphasizes the self-similar partition.
Is this the same as the random midpoint game on a square?
Four vertices with the same midpoint rule fills the square densely—the attractor is not a thin fractal. The triangle case with three maps is special because the three contractions isolate a Cantor-set-like limit in the standard chaos-game normalization.