Project 8 (Philip Prosapio)
Skip to end of metadata
Go to start of metadata

Philip Prosapio
Spring 2010


For the beginning of this lab, we needed to make three functions within our Interpreter class. These functions are goto(), place(), and orient() and make it so importing the turtle module is not necessary in the task files. The next part asked us to make a _str_ function that would allow us to print out a nicely formatted base and rule. The next parts were the main tasks of this project. The first one asked us to make a simple image with at least 2 different L-systems, where at least one of them was a multi-rule L-system. The next task wanted us to make a forest that had at least three different types of trees where one of them was a multi-rule tree. Finally the last task asked me to make up my own L-system and make an image with my L-system having 2, 3, and 4 iterations.

Solution to Tasks

1) The first task was pretty basic, it was very similar to the goto() function we had to make a couple of labs ago. We made a orient, place, and goto function.

2) Making the _str_ function was very difficult. By setting it up as I did, it makes it so every time this function is called it will print the base and rule very neatly.

def _str_(self):
ret = "Base: " + self.base + '\n'
for rule in self.rules:
ret += 'Rule' + rule0 + '->' + rule1 + '\n'
return ret

3) For the third task, I used some of the bases and rules that were provided in lab. I used a multi rule tree and a multi rule fractal for my first picture. For this code, I was able to add in a different form of the drawString() function that would take advantage of the _str_ function that I made in step 2.

terp.drawString( 'T', distance=14, angle=0, text=str(lsys))

The 'T' tells the drawString what what to do with the given information. The picture is attached and labeled picture1lab1.png .

4) For the second task, I needed to make a forest with different types of trees. I used the same random function as I did in the last project. For this I used two tree L-system that were given to me in the lab, but I made my own tree L-system for the final tree. Here is the base and the rule.

base X
rule X BF+F+X-XFX
rule F FF

This L-system made a tree that is slanted to the left. This forest picture is attached and named picture2lab1.png .

5) The third and final task asked me to make up my own L-system and make a picture with 2, 3, and 4 iterations. I decided to make a multi-rule L-system tree from scratch. I like the design of the plant because the many branches come out radially and at a good angle. The base and rule are given below the picture. The picture is attached and labelled picture3lab8.png .


Extension 1- For the first extension, I fulfilled the extension that requires me to add leaves and berries to my tree L-systems. I took my L-system that I created in part 5 and added berries and leaves.

  1. if c is 'R'
    elif c == 'R':
  2. go forward by distance and be colored green

This is the function is what makes the berries on the tips of the tree branches. The picture for my first extension is attached and labelled picture4lab8.png .

Extension 2- For extension 2, I made two new L-systems. The first is a massive tree. It took multiple iterations to become as complicated as it is now. For all of the scene functions that I have used during this project I started out each function with:

terp = interpreter.Interpreter( 800, 800 )

This makes it so whenever I need to call something from within the Interpreter class all I need to do is call terp.blank. The second L-system fractal I made was a complicated shape that was a 1 rule L-system. So the first picture of the new L-system tree is attached and labeled picture5lab8.png and the other picture of my other L-system object is also attached and labelled picture6lab8.png .

What I Learned
For this lab one thing that I learned had to do with built in Python functions and overriding them. When we made the _str_ function, we were making it so it would override the built-in function and do something special that we wanted.

Attached Pictures