CS 151: Project #8

Project 8: Fractals and Trees

Main course page

The assignment is to bring together the lsystem and transformer pieces to make a scene that consists of fractal shapes, trees, and other turtle graphics (think back to projects 2 and 3). Your top-level program will include both the lsystem and transformer modules.


  1. Create a file called scene.py. The file will need to import turtle, turtleUtils, lsystem, and transformer. You may also want to import the random package. Write a function scene1()that creates a simple scene using L-systems. Your scene should include at least one fractal shape and one tree. You can ask the user which L-system files to use or hard-code their filenames into the program. Note that you probably want to add the statement turtle.tracer(False) to the init function in transformer.py (after calling setup) so that the graphics are drawn more quickly.

    Grab a screen shot of your scene and include it in your writeup.

  2. Write a function scene2() that draws a set of 9 trees based on the systemB L-system. Order the 9 trees as a 3x3 grid. From left to right the number of iterations of the L-system should go from 1 to 3. From top to bottom, the angle of the L-system should be 22.5, 45, and 60.
  3. Grab a screen shot of your scene and include it in your writeup.

  4. Write a function scene3() that makes a simple outdoor scene with trees generated using L-systems. Scene 3 should include at least one new L-system. You can use one of the L-systems from ABOP or make up one of your own. Scene 3 should also have trees of different sizes.
  5. Grab a screen shot of your scene and include it in your writeup.


  1. Add random variation to the angles and distances when drawing a tree.
  2. Add leaves, berries, and color to the trees by using additional symbols in the string. You will need to add a case to the buildString function for each new symbol to convert the symbol to some new turtle action.
  3. Demonstrate more L-systems from ABOP or make more of your own.

Code Handin

Hand in your code for this assignment using the Moodle drop box. There will be a drop box for each week's assignment. Hand in your python code file. If there are any specific images required for your system to work, zip them up with your code file.

In the unlikely (we hope) event that Moodle is down when you need to hand in your assignment, please email the python file to Professor Maxwell.

Please do not place code anywhere public. Do not include it in your writeups on the wiki, for example.


Each of you should create your own wiki page for your writeup. The writeup can be brief, but should include the following components.

  1. A brief abstract (200 words or less) describing the project.
  2. A more detailed description of what you did. This week, focus on the separation of the shape representation (a string) and the shape's visual appearance. Explain to the reader how the code uses the L-system rules to generate the string.
  3. Include any images or other output your program created. For this project, include screen captures of your scenes.
  4. Describe any extensions you implemented and show results for them.
  5. Give a brief (1 paragraph) description of what you learned.

Colby Wiki

Please put the label cs151s09proj8 on your writeup page (down below the editing window on the edit tab). Please make sure you type the label exactly as given above.