# Pages CS 151 Computational Thinking Fall 2012 Project8

Project 8 is about using the Lsystem and Interpreter module as class that contains data fields and methods. Task1 is to create a scene of trees and their own base-rule text. Task2 is to create a forest scene composed of at least three different types of trees, which at least one of them is using a multiple rule. Task3 is to create a scene of an modified versions of an Lsystem with three different iterations.

In task1, I have three Lsystem tree: systemB.txt, systemC.txt, and systemF.txt, where the first one is a one-rule lsystem and the last two are multiple-rule lsystem. In my Interpreter module, in the drawstring method, I add some new codes that can read the text in any lsystem and store it into the drawstring methods.

In drawString(self, dstring, distance, color, angle, text=None ):

elif c == 'T':
turtle.pencolor('blue')
turtle.write(text, False, 'center', ('Time New Roman', 14, 'bold'))

To call the text to be drawn in the scene, I call: inter.drawString('T', distance = 14, color ='black', angle = 0, text=str(lsys) )
I use the same methods for all the three trees (lsystem)

In task2, I call for loop to draw each type of tree as many as I want. I randomize the x and y coordinates of the each for each loop so that each tree will be placed randomly in these coordinates. I also randomize the distances of the trees so that I can obtain different sized trees.

In task3, first I make changes in one Lsystem as shown below:

Original Lsystem:
base F
rule F-> F+FF-FF

New Version:
base F
rule F -> F-FF-F-F[+FF+F+F]

Then I set iterations to 2, 3, and 4 and I obtain the scene as required.

In extension, I choose to create a scene that has some modification on each tree’ angle and distance.
I also change the methods of creating the forest by randomization the x-coordinates of each three called in each y-position that is looped through five time each.

Labels