# Pages CS 151 Computational Thinking Fall 2012 Project 8 Better Trees

Go to start of metadata

Summary:

The task for this project was to learn how to create more complex lsystems, with multiple rules. We were also not allowed to use the turtle module and therefore had to call the drawString function in the interpreter file to draw pictures.

Description:

In the first image, I used three lsystems and added the rules below the pictures. I created the T character in drawShapes that draws the text that I wanted printed out. I also created the function setText, which the T character called upon. I positioned the picture and text by using the place function and drew the picture by using the drawShapes function. The image is below.

Picture 1:
In the second picture, I created the task2.py file that created four different trees, of different seasons, and had leaves below them. I used for loops to create three tree of each season and used a nested for loop to randomly place between 20-40 leaves on the ground. I used code similar to Bruce's to place the leaves on the ground. The image is below.

Picture 2:
For the third task, I created the task3.py file that created a scene using three different lsystems. The first lsystem was used to create a pond and I did this by calling the pond.txt file and using a for loop to place the different lsystems around. I had them overlap so that the pond appeared darker in certain areas, resulting in deeper water. The second lsystem shows the edited systemB.txt code. I added leaves to the code and a new rule. I placed the trees around the pond at iterations of 2,3, and 4. The iterations above 4 took a long time to create. The code is below for the new and old lsystems.

Old: base F
rule F FF-[-F+F+F]+[+F-F-F]

New: base F
rule F Ff-[F+F+F<gL>]+[F-F-F<gL>][-F+F+F<gL>][+++F-F-F<gL>]
rule f FFFF

In the third lsystem, I edited one of the trees found in the ABOP book to include berries and leaves. I used a for loop to randomly place 40 of these trees of random iterations, between 2 and 5, around the top of the pond. The code and picture are below.

Old: base X
rule X F{+X][-X]FX
rule F FF

New: base X
rule X F[+X<gL>][-X<gL>][X<gL>][F<rN>]FX
rule F FF

Picture 3:
Extensions:

In both the second and third images, I used for loops to add many of my trees and lake lsystems around the screen. I also used the random module to help put the trees all over the pond randomly and of different iterations resulting in different sized trees. I also added berries to the second tree that I created. I added different characters to the interpreter such as N for berries, and m,n,o,p for the different seasons and L for the leaves.

Conclusion:

In this project, I learned how to call the drawString function to create shapes rather than using the turtle module directly. This helped create more complex pictures, with simpler code. I am excited for the next project to learn more about calling the drawString function to create more interesting shapes. I also learned how to add text to the picture and used that in the second picture.

Labels