React-sim
GitHub
Code for this example

Chaos Game

0
10000

The Chaos Game is a method to generate a fractal.

We start from an equilateral triangle, and one point chosen at random in the plane. At each iteration, we plot a new point which is halfway between the previous point, and one of the vertices of the triangle, chosen at random. We continue plot points like these.

Eventually, our figure looks like the SierpiƄski triangle

0
20000

But we can generalize this to other polygons. In this second version, we can choose a regular polygon with 3 to 12 vertices (so, anything from a triangle to a dodecagon). We can also choose whether we use each vertex as an attractor or not. If a vertex is not an attractor, it won't be used to compute the position of new points in iterations.

For larger polygons, if all vertices are used as attractors, the resulting figure looks a bit messy. But if we only pick a few, then shapes will start to emerge.

One interesting pattern is for polygons with odd number of vertices, if vertices = 2 x n + 3. You can try:

  • set the first vertex,
  • leave n vertices unset,
  • set the next 2 vertices,
  • leave the last n vertices unset.

So: 1 0 1 1 0 for 5, 1 0 0 1 1 0 0 for 7, 1 0 0 0 1 1 0 0 0 for 9, etc.

Edit this page on GitHub
Previous:
Boids
Next:
Dice simulator
React-SimGitHub