Jonathan's CS151 Project 8
Skip to end of metadata
Go to start of metadata


The purpose of this project was to expand our knowledge on L-systems. Last project, we took L-systems with a single rule and created images and scenes with them. Now, in project 8, we learned how to use L-systems with more than one rule. We took many pieces of code from our last project, expanded it, improved it, and overall made it a better code. 

Task 1:

For this project, we needed to update our turtle_interpreter class. This is the class that reads in a string of commands and uses the turtle to draw that string. Previously, we had no code in this class that allowed python to read in commands such as color and color stacks. I added code to this class that started allowing python to read in certain characters as color changes in the image. Below is a snippet of the code that I added to this class:

Adding these lines of code really helped improve my code an allowed python to read in more complicated strings.
Task 2:
The second task of this project was to create a scene that called at least two 2 rule L-systems. These L-systems needed to draw trees that had some type of leaf or berry on it. This would ensure our usage of the color store/restore. Below is my scene for the second task:

I used three different L-systems in this scene. The first two (going left to right) have only leafs on them. However the last one has both leafs and berries. It is important that this task was completed as it is the main objective in this project.
Task 3:
Task three asked us to use two new L-systems. During this task, we needed to show the growth in our trees by setting the same tree to draw three different times with three different iterations. For this task, I took two L-systems from the ABOP book that code trees and added leafs to them. Below is an image showing the growth in my trees:

This image also shows the original L-system on the left, and the new L-system on the right. Below is both of my task 3 scenes:

Both of these scenes show the original L-system on the left with no leafs, and the new L-systems on the right with leafs. It also shows the growth in each one of the trees, as each tree to the right grows by one iteration.
For my first extension I added to my turtle_interpreter code. I added a piece to that code that allowed the base of my trees (the branches) to be brown. This would add a more realistic touch to the trees. Below are two images of my new scenes with this added code:

This new code definitely makes my trees look a lot better.
For my second extension I got fancy with my coding. Instead of individually calling trees to different locations, I created a for loop that called a certain amount of trees in an area that I specified within the for loop. It would also randomly place those trees within the area. This new code is below:

This code definitely made my entire code better, neater, and more efficient. 
What I learned: During this project I learned a lot about L-systems. In particular, I learned how to use L-systems with more than one rule. These are really useful tools to know. Also, I learned how to effectively modify a string in order to add to or make a tree better. Project 8 was a really useful project.
Acknowledgments: Prof. Li, Prof. Taylor, Riley Janeway