The Chaos Game
(Iterated Function Systems)

Very brief instructions: A Chaos Game is determined by a set of two or more "maps". Each map represents an image of the unit square, which is shown in white in the applet. Select an example from the "Examples" menu or add individual "maps" using the "Add Map" menu. A map is shown as a square, rectangle, or parallelogram with colored edges. One of the maps can be "selected" by clicking on it; the selected map has handles and arrows that can be dragged to edit the map. To de-select all maps, click somewhere outside of all the maps or use the "Select No Map" command in the "Control" menu. The "chaos game" runs whenever there are at least two maps. The purpose of the game is to produce images that are made up of dots that are produced by a semi-random process based on the maps. If a map is selected then a preview of the game is shown in the form of a small number of magenta-colored dots; if no map is selected, then the real game is run and an image made of small black dots -- or colored dots if the "Color Code Maps" menu option is selected -- is gradually built up. Use the "Show Maps" menu option in the "Control" menu to turn off display of the maps and get a better look at the image.

When editing a map, you can drag the corners to change the size of the map. To rotate the map, you can drag the arrow that is attached to the center of the map. You can drag the arrows on the sides to "skew" the map, or drag the sides themselves to change the size of the map in one direction only. Finally, if you click anywhere else in the map, you can drag the map as a whole. You can use the right mouse button, or hold down the shift key when you click with the left mouse button, to modify the effect of any of these edit operations. If you do this while rotating the map, the rotation is limited to multiples of 15 degrees. If you do it while dragging the map as a whole, the motion is limited to a horizontal-only or vertical-only motion. If you modify the other edit operations, the center of the map will be fixed during the operation. (Just try it.)

To run the Chaos Game, the following process is applied: Start with a randomly selected point in the unit square. Then repeat the following some specified number of times: Choose one of the maps at random, and move the point from its current location to the corresponding point in the chosen map. Draw the dot at its final position (only the final position of the dot is shown). This process is repeated over and over to produce the dots that make up the image. The image that is produced is a fractal that is made up of transformed and scaled copies of itself; each map corresponds to one of the copies. (For this to work properly, the copies must be smaller than the original -- the applet does not guarantee that this is the case.)

For more information about the Chaos Game and Iterated Function Systems, you can take a look at the Widkpedia IFS article and the links on that page.

Note: I wrote this applet in March 2008 for one class in an introductory math course for non-math majors when I couldn't find an existing Chaos Game applet on the web that I thought was easy enough to use. It requires Java 5.0 or higher. It does not have all the features that I would like to see in a Chaos Game program, but I decided to make it available anyway since I will probably not do any more work on it in the near future. You can browse the messy and completely uncommented source code on-line if you want. And you can download an executable jar file that can be used to run the program as a stand-alone application (which will allow you to save images and to save and load map data files). On most computers, you can just double-click the jar file to execute it.

David Eck, March 2008