## Chaos Game Explorer

- Fractals are patterns in space or time, or both, that repeat themselves at different length scales of observation, describing shapes made of parts similar to the whole in some way (Mandelbrot, 1982; Feder, 1988). These patterns are relevant to many fields: From the study of natural growth phenomena to the study of electrochemically deposited materials, to mention a few (Takayasu, 1990).
- There are plenty of mathematical methods for the modeling and construction of fractals. One of the most famous method is the Chaos Game Algorithm, invented by Professor Michael Barnsley and described in
*Fractals Everywhere*(Barnsley, 1988) and*The Desktop Fractal Design HandBook*(Barnsley, 1989). The algorithm randomly places an initial point p(x0, y0) inside or outside an n-gon. - For a planar regular n-gon (e.g., a regular triangle) there must be as many vertices as edges (Kaufman, 2013). As a vertex is defined as a point where two or more edges meet, and since there is no such thing as a fractional point, n must be an integer; so the tool will round off n if the user attempts to set it as a fractional value.
- Points at the vertices of the n-gon are classified (numbered or color coded) and a new point p(x1, y1) at a fraction r of the distance between p(x0, y0) with the closest vertex is classified accordingly. Next, p(x1, y1) is taken for a new p(x0, y0) and the process is repeated over and over N times. The sequence of classified points quickly converges to a pattern. The game might return some few initial outliers, but these are filtered out without affecting the pattern. Frequently, though not always, the result is a fractal pattern.
- Either way, the algorithm returns the attractor of the iterated function systems (IFS) implemented. IFS were originally conceived by John Hutchinson at the Australian National University, Canberra (Hutchinson, 1979) and later popularized by Barnsley at the Georgia Institute of Technology, Atlanta (Barnsley, 1988).
- Over the years, several excellent modifications of the chaos game have been described (Wikipedia, 2018; Devaney, 1996). This tool, the Chaos Game Explorer, is based on Barnsley's original algorithm. The tool helps users replicate many of the fractal patterns found in the literature (Weisstein, 2018), and even discover new ones (see Suggested Exercises section).
**Using the tool**: To use the tool, complete all form fields; otherwise the tool will reset itself. Proceed as follows:- iterates, N: Enter a large value like 100000. A larger N improves resolution, but slows down the program.
- vertices, n: Enter a value equal or greater than 3.
- scaling, r: Enter a nonzero real value.
- colors mode: Select the "white" or "colored" option to respectively grasp local or global details. However, selecting "colored" instructs the tool to assign a set of randomly selected colors, so repeating a run with this option can return the same pattern with different colors.

**First time users**: If using the tool for the very first time, you may want to try the example provided.**View/Save**: Use your browser to view/save the output. You can always copy/paste an image to the computer clipboard memory and crop it with Photoshop, Paint, or similar software. You may edit or use the generated images as you please and without copyright limitations.- This tool is powered by our Minerazzi Grapher, a lightweight PHP class that generates all kind of graphs through a web browser. No additional libraries or software are needed.

In his handbook, Barnsley used the following example to illustrate how the algorithm works. Note that he used a triangle (n = 3), r = 1/2, and recommended a large N value, actually in the millions. He also used a numbering system to classify points and vertices.**Origins of The Chaos Game Algorithm**"Suppose now that you have a die which only shows the numbers 1, 2, and 3 on its faces. Here is how the Chaos Game is played: Mark the three fixed points on a piece of paper, and label them 1, 2, and 3. Choose one additional point wherever you like on the paper. Call it (x0, y0). Roll the die. Mark the midpoint between the point labelled with the same number as shows on the die and (x0, y0), and label this new point (x1, y1). What you have done is to apply the transformation selected by the roll of the die to the point (x0, y0). Again roll the die. Mark the midpoint between the point labelled with the same number as shows on the die and (x1, y1), and label the new point (x2, y2). Repeat this process over and over again to obtain a long sequence of points, preferably millions of them..."

The result of playing the game in this way is the Sierpinski Triangle, one of the most famous fractals. Feel free to reproduce this pattern with our tool. The tool will compute the corresponding pattern and its fractal dimension D where

D = log(n)/log(1/r).

At this point you might wonder where the name of the game came from. Barnsley wrote in his handbook:**Origins of the Game Name**"The Chaos Game Algorithm is the name we use in the Desktop Fractal Design System for the Random Iteration Algorithm, as defined in

*Fractals Everywhere*. How do we know that this algorithm will produce the same image over and over again, independent of the particular sequence of random choices that are made? This remarkable result was first suggested by computergraphical mathematics experiments and later given a rigorous foundation by Iterated Systems Inc.'s mathematician John Elton."**Applications to DNA Sequences**The Chaos Game has found practical applications as a method for representing gene strutures and DNA sequences (Jeffrey, 1990), and as a tool for graphical representation of English text and genetic sequences. The game provides a visual image of a DNA sequence that is different from the traditional linear arrangement of nucleotides (Aswathi, 2009).

Recently, Yin (2017) proposed a novel method based on a variant of the chaos game for encoding a DNA sequence into three integers, containing all sequence information, and with possible applications to DNA sequence compressions, encryption, and steganography.

**Ongoing Research**We are currently testing some modifications of the algorithm. We expect to document the results online so third parties might be interested in reproducing them.

- Students, teachers, and researchers interested in Fractal Geometry.

- Construct fractal patterns with n-gons of unequal sizes, by setting n to a non integer, like n = 3.5, 4.44, 5.67, and so forth.
- Explain the effect of increasing r above 0.5 on a fractal pattern generated with a given n-gon.
- Explain the effect of decreasing r below 0.5 on a fractal pattern generated with a given n-gon.
- For n = 3 and n = 4, r = 0.5 is a critical scaling factor in the sense that playing the chaos game with these values generates fractal patterns that are neither overlapped nor disconnected. Find a critical r for other n-gons. Then make a plot of these r's versus the corresponding fractal dimensions. Draw conclusions.
- Given a fractal dimension and scaling ratio, generate the corresponding pattern.
- Given a fractal dimension and number of vertices, generate the corresponding pattern.
- Compare fractal patterns obtained using a given n-gon, where r is defined as the inverse of the following universal constants:
- r = 1/g = 1/1.61803... (g = Golden Mean)
- r = 1/pi = 1/3.14159... (pi = circle's circumference/diameter constant)
- r = 1/e = 1/2.71828... (e = Euler's constant)
- r = 1/f1 = 1/4.66920... (Feigenbaum's first constant)
- r = 1/f2 = 1/2.50290... (Feigenbaum's second constant)

- Reproduce the fractal patterns given in the Wolfram site (Wolfram, 2018).

- Aswathi, B. L. (2009). Chaos Game Representation. Centre for Bioinformatics, Kerala University.
- Barnsley, M. F. (1988).
*Fractals Everywhere*. Academic Press, Inc. New York. - Barnsley, M. F. (1989).
*The Desktop Fractal Design Handbook*. - Devaney, R. L. (1996). The Chaos Game.
- Feder, J. (1988).
*Fractals*. Plenum Press, New York. - Hutchinson, J. E. (1979). Fractals and Self Similarity. Research Report No. 31-1979, Department of Pure Mathematics, Faculty of Science, Australian National University, Canberra, Australia. Link is a 1981 TeX'd version of the article from Indiana University Mathematics Journal 30, 713-747.
- Jeffrey, H. J. (1990). Chaos Game Representation of Gene Structure. Nucleic Acids Res. Vol 18, No. 8, 2163-2170.
- Kaufman, R. (2013). The Convex Deltahedra and the Allowance of Coplanar Faces.
- Mandelbrot, B. B. (1982).
*The Fractal Geometry of Nature*. Freeman, New York. Online version. - Takayasu, H. (1990).
*Fractals in the Physical Sciences*. Wiley, New York. - Wikipedia (2018). Chaos Game.
- Weisstein, E. W. (2018). "Chaos Game". From
*MathWorld*--A Wolfram Web Resource. http://mathworld.wolfram.com/ChaosGame.html. Retrieved on 2018. - Yin, C. (2017). Encoding DNA sequences by integer chaos game representation. arxiv.org: 1712.04546.

#### Feedback

Contact us for any suggestion or question regarding this tool.