๐น๏ธ Chaos game
Chaos game fractals ๐ฎ
Section titled โChaos game fractals ๐ฎโ๐ฏ Improved understanding of the chaos game
๐ง Inspired by nnakul/chaos-game by Nikhil Nakul
๐ A VPython version is available as well, see chaos_game.py
About the chaos game
Section titled โAbout the chaos gameโThe chaos game is an iterative procedure that can be written as an affine transformation
where the set of pairs with matrices and characterize the chosen ruleset and denotes a (per iteration) randomly chosen index. The famous Barnsley fern is generated in a similar way.
Why do fractals arise from the chaos game
Section titled โWhy do fractals arise from the chaos gameโThe chaos game is an iterative process of placing dots on a canvas using certain fixed locations (vertices) that are chosen randomly. For example, in the animation below, the position of each new dot is halfway between the current position and one of the three fixed corners of a triangle.

Source Wikipedia
Letโs assume we start with a point that is located in one of the areas that will eventually be empty, see the figure below.

Source BU Math
After one iteration, the point will jump to either one of the three smaller empty triangles. Eventually after a couple of iterations, the point will enter a small triangle that is so small that, given the finite resolution of the screen and the pixels it contains, it will disappear.
In a certain sense, the fractal itself is a kind of strange attractor!