Chaos game – building triangles out of randomness

The Chaos game refers to the emergence of fractal patterns with random numbers when the selection of random numbers are subject to some constraints. Let's look at the rules of one of the simplest chaos games:

  1. We start by creating three points on a plane to form a triangle.
  2. To begin the game, we draw a random point inside the triangle.
  3. We then roll a dice. Given the outcome, we move halfway between the last point and any one of the vertices of the triangle. For example, if the outcome is 1 or 2, we move halfway between the last point and vertex A. If the outcome is 3 or 4, we move halfway from the current point towards vertex B, or if the outcome is 5 or 6, we draw the next point halfway ...

Get Tkinter GUI Application Development Blueprints - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.