Project 3: Chaos and Iterated Function Systems

Due: Tuesday 9 October 2007


The Code

In this project you are asked to add a method to called drawChaosGame() that takes an integer argument representing the number of rounds the Turtle plays the chaos game. As always, you must implement at least one helper method in addition to drawChaosGame().

The chaos game is actually a framework for drawing what are known as iterated function systems (IFS). The dynamics of iterated functions can lead to truly complicated and mathematically rich pictures. (For those who're interested, check out the pictures that come from Indra's Pearls, a rather accessible book on the complex dynamics of Mobius transformations. There are even some movies, too.)

As we have seen in class, the general strategy for playing the chaos game is this:

  1. Pick a point at random
  2. Randomly apply any of several, predefined functions to the point.

    In our Sierpenski's gasket example, the functions were: move half the distance to a random corner of the triangle and set the pen color according to the corner that was selected.

  3. Draw the result on the World.
  4. Repeat for some specified number of iterations.

For this project, you need to implement a chaos game on an n-polygon with n≥4 and functions of your choice. (Note: The square is a bit trickier than you'd expect. Bonus points for anyone who can implement Sierpenski's carpet.)

The example below depicts a Serpenski (regular) hexagon. The middle interior curve is another well-known fractal called Koch's snowflake. (Wikipedia even supplies code for the Turtle to draw the snowflake on its own. If you have extra time, see if you can translate the Logo turtle code to Java turtle code.)

Sierpenski's hexagon


Also, be sure to comment your code fully, explaining your intention for method and field you create and which parameters, if any, they take. Prefix your Turtle class file with comments that include your name, course title, date, and the project number and title. For example:

// Joshua Reyes
// CSIT 114
// 9 October 2007
// Project 3: Chaos

Notice that because your method accepts a single integer parameter, it will take the form:

public void drawChaosGame(int interations) {

	// The body of your method here.

The Write-up

Once you have implemented the method above, write a short (couple paragraph) essay detailing your experience programming in a plain text file called memo.txt. (Do not use an editor like MS Word.) Here are some questions to keep in mind:

If you worked with others, explain what each person contributed to your project. Cite others appropriately. Even if you worked with others, the code you pass in ought to be your own.

Turning the Project In

Use a secure FTP client to create a subdirectory of csit114 called project3. Upload your and memo.txt to that directory by Tuesday, 9 October 2007. Please make sure that your file names are spelled correctly. It is frustrating for me to have to search for your files by hand.


RequirementAdvancedProficientNeeds ImprovementMaximum Points
Comments and Coding Style Well commented. Code conforms to naming and style conventions. Mostly commented. Code mostly conforms to naming and style conventions. Few or no comments. Code does not conform to conventions. 15
Compiles Compiles without error. Compiles without error. Does not compile. 3
drawChaosGame() Is named correctly, implements an IFS with a polygonal frame, and calls at least one helper method. Is named correctly, implements an IFS with a polygonal frame, without a call to any helper methods. Is neither named correctly nor implements an IFS nor calls any helper methods. 7
Code Structure Modular design: most repeated patterns in code are stored in individual helper methods or executed using loop constructs. Semi-modular design: Blocks of code that perform a different tasks are logically and physically separated. There is heavy evidence of copying and pasting throughout the code. 10
Analysis Provides clear and complete exposition of the design and implementation process. Provides a mostly clear and nearly complete exposition of the design and implementation process. Provides an unclear and incomplete exposition of the design and implementation process. 15
Grammar and Style Well written. No obvious grammar or punctuation errors. A pleasure to read. A few grammatical errors such as punctuation or spelling, although most errors do not interfere with the overall message or the substance of the text. Many grammatical errors including punctuation, spelling or usage problems. 10
Organization Written work is neat and well organized. Written work mostly organized. Written work messy and disorganized. 5
Total 65