Due: Tuesday, April 11, 2017, 11:59 pm
As with last week, the assignment is to bring together the lsystem and turtle interpreter classes to make a scene that consists of fractal shapes and trees. Your top-level program will import both the lsystem and turtle_interpreter modules. Unlike last week, however, your main programs (arrangement.py and growth.py) may not import the turtle module or make any calls to turtle commands directly. If you want to draw something, you have to pass a string to the interpreter drawString method. There will be no exceptions to that rule. (Note that you may attach arbitrary meaning to any character not used by an L-system grammar.)
We want to be able to change the color of elements in an Lsystem without affecting the color of other elements. We would also like to avoid setting colors, widths, or other turtle drawing features by adding new parameters to drawString. Modify your drawString method so that it supports five additional characters in the strings. Don't forget to update the docstring of drawString to include the new characters
turtle.color() to get the turtle's
current color. Note that this function returns a tuple of colors.
You should append just the first element of the tuple onto the
color stack (e.g. turtle.color()[0]).
Once you have made the modifications to drawString, try running systemFL using the classtest.py test function from the lab. You can also use the test function single.py to draw just a single tree.
At least two of the L-systems you use must have at least 2 rules. Like last week, please hard-code the filenames for the L-systems into your code, so that we can run your program without needing command line arguments.
|
|
|
|
|
| systemCL | systemDL | systemEL | systemFL | systemGL |
This is required image 1.
If you use a variation, include both the original and your variant in your writeup. (The difference does not have to be large.)
In the file growth.py, create a scene function that makes an image using your L-systems after 2, 3, and 4 iterations. Note, if using a different pattern of iterations is more interesting (e.g. 4, 5, 6) you are free to use a different set of three iteration values. Indicate what you used in your writeup.
Again, please hard-code the filenames for the L-systems into your code, rather than rely on command-line arguments. Also, be sure to put a copy of your new L-system's text file on the Courses server when you turn in your code.
This is required image 2.
In the Lsystem class create a method def __str__(self)
that returns a nicely formatted string that might look like the
following when printed.
base X rule X -> F-[[X]+X]+F[+FX]-X rule F -> FF
The __str__ method gets called automatically when an object is printed out. It's also called to implement casting an object to a string using str(thing). Note that your __str__ method should not print anything out. It should build a string from the information in your L-system and return the string. Remember that '\n' is how you create a newline character.
In the test main function the line:
print lsys
should print out your nicely formatted string instead of the generic class instance string when you run your lsystem.py file.
See if you can draw the base string and rule below the image of a tree from that L-system.
Turn in your code by putting it into your private hand-in directory on the Courses server. All files should be organized in a folder titled "Project 8" and you should include only those files necessary to run the program. We will grade all files turned in, so please do not turn in old, non-working, versions of files.
Make a new wiki page for your
assignment. Put the label cs151s17project8 in the label field
on the bottom of the page. But give the page a meaningful title (e.g.
Ying's Project 8).
In general, your intended audience for your write-up is your peers not in the class. Your goal should be to be able to use it to explain to friends what you accomplished in this project and to give them a sense of how you did it. Follow the outline below.
cs151s17project8To check whether you've made your images and their text clear, you may ask yourself the following questions:
© 2017 Ying Li. Page last modified: .