Project 10

The goal for this week's project was to use the Zturtle class that we created in lab in order to use turtle and zelle graphics in the same scene. We were also asked to employ dictionaries in our program instead of lists. Ultimately, we combined some of the images from our cities and trees from previous projects, made use of dictionaries, and incorporated several of the other tools we have been working with in order to make a more interesting image.

Lists and Dictionaries:

The elements of a list are indexed numerically, whereas a dictionary stores its data based on key/value pairs. In our lsystems, for instance, a key would be a symbol and a value would be a replacement symbol. The dictionary is appropriate for this project because instead of a searching through a list for the proper rule, you can use the key to access the replacement rule immediately.

To create my final scene, I imported my zturtle, lsystem3, and city2 files. This way, I was able to work with both turtle and zelle graphics, use the Lsystem class to generate the designs using lsystems, and use my buildings from project 6. I created 3 different lsystems, one of which with 2 possible rules. I appended each of these to a list (systems), and then used a for loop to go through each lsystem and draw each tree, changing the x-axis value each time through. This loop cut down on code and made it easier to move the trees around my image until I was satisfied with it.

Here are my lsystems:

( 'F', [['F', 'fF[+FR-]F[-F+][+FL][FO]'] ], 4, 22.5, 5 )

( 'F', [['F', 'FR[+FL]FL[-FO]F'], ['F', 'F', 'fF[+FR-]F[-FG+][+FL][FB]']], 4, 23, 4 )

( 'F', [['F', 'fF[+FR-]F[-FG+][+FL][FB]']], 4, 26.2, 3.8 )

Here's the final scene: