Ultimate CHAOSNew fun with fractals.
By Roger Pruitt
Experiment with the new mathematics of chaos with this program that creates the Sierpinski gasket -- and lets you add your own factors to generate some highly unusual fractal patterns. This BASIC program works on 8-bit Atari computers with at least 48K memory and disk drive. An Epson-compatible printer is optional.
In physics and other sciences, the term "chaos" has come to mean the study of deterministic disorder. This is a relatively new field that integrates many subdisciplines of mathematics and the sciences. Chaos covers the study of fragmented and irregular fractal shapes such as clouds, mountains, coastlines, and tree bark, which all exhibit increasing detail when magnified.
In addition, chaos involves the study of non-linear dynamic systems exhibiting unpredictable and random behavior. Studies of biological populations, climate processes, economic fluctuations and the dynamics of Jupiter's Great Red Spot are all covered in the same discipline as studies of fractal shapes.
The word fractal was coined in 1975 by the mathematician Benoit Mandelbrot to describe his shapes, dimensions and geometry. The word itself is a contraction of "fractional dimensions," but most people think of fractals simply as shapes that are self-similar.
A coastline, for example, has a highly irregular fractal shape. As its structure is magnified, more of its irregularity is revealed, but the sort of shapes formed by the coastline remain the same, whether you are looking close up at a small inlet or from a satellite at a major bay.
In studying fractal shapes, a number of patters have been identified. The Mandelbrot set, Koch curves and Sierpinski gaskets are some well- known examples of fractal shapes. (See Charles Jackson's excellent article in the April 1986 Antic for more on fractals and the Mandelbrot set, also known as the Julia curve.) All these shapes result from deterministic processes.
To make a Koch snowflake curve, begin with an equilateral triangle. At the middle of each side, add a smaller triangle one-third the size of the original triangle. This results in a six- pointed figure. At the middle of each side of this figure add still smaller triangles, and so on.
To make a Sierpinski gasket, start with another equilateral triangle. Divide the triangle into four smaller triangles by drawing lines from the middle of each side to the other two sides. Remove the central triangle. Repeat the process with the remaining three triangles and remove the central triangle from each of them. Nine still smaller triangles remain. The process continues infinitely in the fractal, even if it becomes impossible to actually draw the ever smaller triangles with ordinary pencil and paper -- or computer screen.
Rather than generate fractal shapes from such deterministic processes as just described, Michael Barnesley of the Georgia Institute of Technology takes a different approach. He constructs fractals through a random process he calls the Chaos Game.
Listing 1, GASKET.BAS, is a short demonstration program. Type it in, check it with TYPO II and SAVE a copy to disk. Now type in Listing 2, CHAOS.BAS, check it with TYPO II, and SAVE a copy to disk. Antic Disk users will find both of these programs on this issue's disk.
If you have trouble typing Listing 2 because of the special characters in lines 28360, 28370, 28400 and 28410, don't type them in. Listing 3 will create these hard-to-type lines for you. Type in Listing 3, check it with TYPO II, and SAVE a copy.
When you RUN Listing 3 it will create a file containing these hard-to- type lines called LINES.LST. (Make sure you don't already have a file by that name on your disk.) Merge this file into Listing 2 by typing LOAD "D:CHAOS.BAS" and then ENTER "D:LINES.LST". Be sure to SAVE the final version of the Ultimate Chaos file.
When you RUN the shorter demonstration program GASKET.BAS (Listing 1)
by itself, it generates a Sierpinski gasket according to Barnesley's method.
You'll see the distinctive triangular patterns generating in about five
or 10 minutes. In the program, the vertices (points) of a triangle are
located at the screen coordinates (0,0), (319,0) and (159,191). These vertices
are respectively designated as 1, 2, and 3.
First the computer randomly picks a point anywhere on the screen. Next, one of the vertices is randomly chosen. A point is then plotted (drawn) halfway between the initial point and this vertex. From this point a second point is plotted halfway to the next randomly chosen vertex. The process is repeated over and over.
At first, the process appears to randomly place dots all over the screen. However, after a short period of time the pattern of the Sierpinski gasket begins to emerge. It is fascinating to watch order appear from chaos.
Instead of dividing the distance from the last plotted point to a randomly chosen vertex by two, I wanted to see what would happen if the distance were divided by three, or something else. Then I wondered what kind of fractal patterns would be generated for polygons of more than three sides. After a little thinking I realized I could write a general program that would let me study all the variations. The resulting program is Ultimate Chaos.
When you RUN Ultimate Chaos, you will see two Menu items on the screen. With option 1, Create Chaos, you can generate fractal patterns for polygons with up to 10 sides, using different scale factors to determine where points will be plotted. First, you will be asked to enter a name for your picture -- to be used as a filename if you choose to save your fractal image later. Enter a name with up to eight characters and press [RETURN]. The program will automatically supply .PIC as the filename extension when you are ready to save the picture to disk.
You will next be asked to input the number of sides your polygon should have. You can enter any number from 1 through 10, including fractions (in decimal form). A triangle is a three- sided polygon. If you enter 3 for the number of sides, then at the next prompt enter a scale of 0.5 (one half). With this scale the distance between the last plotted point and a randomly chosen vertex is halved and a new point is plotted on the screen. The result should be a Sierpinski gasket very similar to the ones produces with GASKET.BAS.
Other scale factors cause new points to be plotted closer or further from the vertices -- the smaller the scale factor, the close the points will be to the vertices. A scale of .333 (one third) results in smaller triangles clustered at each vertex. With scales over .5, points begin to overlap, gradually filling in some polygons. A scale of 1 will result in all new points being plotted precisely on top of the old one.
For a truly odd shape, a scale of .99 produces a crawling line that eventually reaches the center of the polygon and stays there, moving slightly back and forth between the randomly- chosen vertices.
Experimentation will show that different scale factors work better with different polygons. A scale factor of 0.4 works well for a five-sided pentagon, while smaller scale factors produce nice results for polygons of more sides. Further interesting patterns result from choosing a non-integer value when the prompt asks for the number of sides for the desired polygon. For example, you might try a 2.5 sided polygon with a scale factor of 0.3.
SAVE & PRINT
Once you have a fractal pattern you like, you can save it simply by pressing [SELECT]. You will need to have plenty of free space on your disk, as each picture is saved in Micro-Painter format requiring 62 sectors. (Micro- Painter images may be converted to Micro Illustrator format with Rapid Graphics Converter from the November 1985 Antic.)
If you have an Epson-compatible printer, you can also print your picture by pressing [OPTION]. To return to the main menu, hold down [START] and the press [OPTION].
You can load your pictures back into the Chaos Game by using option 2 on the main menu, Load Picture. Make sure you know the name of the picture you want before you choose this option. The program will add the extender .PIC to the filename for you, and load the picture from the disk in drive one.
For more information on fractal geometry and the Chaos Game, "Chaos: Making a New Science" by James Gleick (Viling, 1987, ISBN 0-670- 81178-5) is an excellent introduction to chaotic phenomena, even for non- mathematicians.
Roger Pruitt is a Professor of Physics at Fort Hays State University in Hays, KS. His physics department has eight Atari 8- bit computers for student use, six of them networked with a Supra MicroNet and MicroStuffer, and interfaced with various laboratory detectors for data collection and reduction.