The Chaos Game
About
The Chaos Game is a method of creating fractals using a polygon and a point that moves between the vertices of that polygon.
Sierpinski triangle Sierpinski carpet Sierpinski pentagon
The point starts at any position and continuously jumps towards a random vertex by a determined factor, drawing wherever it lands. To generate the Sierpinski triangle, the point jumps towards 1 of the 3 vertices at random by a factor of 1/2. The Sierpinski carpet requires additional vertices at the midpoints of the four edges and jumps between these vertices by a factor of 2/3. The Sierpinski pentagon is generated by jumping between the 5 vertices by a factor of 1/phi. Note: There is currently a bug making the pentagon draw improperly in some color modes.
- Z - Pause/Resume
- X - Cycle through fractal shapes
- Left/Right - Change color mode
- Up/Down - Change speed
If you found this interesting you might also like my recreation of Conway's Game of Life.