CS 151: Project #9

Project 9: More Trees

Main course page

As with last week, the assignment is to bring together the lsystem and transformer classes to make a scene that consists of fractal shapes and trees. Your top-level program will include both the lsystem and transformer modules. Unlike last week, your scene.py should not include the turtle module or make any calls to turtle commands. If you want to draw something, you have to pass a string to the transformer drawString function. There will be no exceptions to that rule.


Tasks

  1. You need to add a little more functionality to your transformer class in order to avoid calling turtle commands in your scene function. Add the following methods to the transformer class.
    • def place(self, xpos, ypos) - the function should pick up the pen, put the turtle at xpos, ypos, and then put the pen back down.
    • def orient(self, angle) - the function should use the turtle setheading function to orient the turtle to the given angle.
    • def wait( self ) - the function should call the turtleUtils wait function.

    Now you can use the place and wait methods of the transformer class to put your trees in different locations and orientations on the screen.

  2. Create a file called scene.py. The file will need to import lsystem2 and transformer2. You may also want to import the random package. Write a function scene1()that creates a simple scene--two different trees, for example--using L-systems that have two or more rules. Create a different Lsystem object for each different type of L-system in your scene.

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

  3. Write a function scene2() that creates a random forest of at least 10 trees. There should be at least two types of trees, and the trees should be somewhat different in sizes and angles, even if created using the same L-system rule set. Create a different Lsystem object for each different type of L-system in your scene.
  4. Grab a screen shot of your scene and include it in your writeup.

Extensions

  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. Make your own L-systems.
  4. Demonstrate how to make other kinds of shapes by passing strings to the transformer's drawString function.

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.

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

Writeup

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 how using a class to hold the L-system information is different than using a list. You should also explain the algorithm for the new replace function.
  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 cs151s09proj9 on your writeup page (down below the editing window on the edit tab). Please make sure you type the label exactly as given above.