The Problem

Modify the L-system program we showed in class to have some new features. Here is the program to modify for this assignment: yurtlehw5.py. Rename your program to lsys.py!

  1. Add color increment and decrement instructions. In yurtlez.py you will find a list of color names called colorlist. Initial color is color number 0 in the colorlist. When an '(' instruction is found it will increment the color number which is used as an index into the colorlist. The pen will immediately be set to the new color. Color numbers will wrap around when it reaches the end of the colorlist. ')' should decrement the color list.

  2. Add the color increment and decrement to the '[' and ']' instructions respectively.

  3. Augment the definition command ("=") and dictionary. A definition can be either:
    =Astuff
    
    or
    =Astuff:morestuff
    
    Note that the ":" (colon) character is a separator character. Instead of assigning a string value to the letter it assigns a tuple of: (stuff, morestuff). In the two examples above under the key "A" is stored (stuff, "") in the first case and (stuff, morestuff) in the second case.

  4. Use the augmented tuple definition above. When the instruction is "A" in the input stream, as in the example above, and the depth < depthLimit then "A" is replaced by def["A"][0] and the depth is incremented. If the depth>=depthlimit then "A" is replaced by def["A"][1] and depth is not incremented nor is the terminating backslash used in the replacement (see the code you have to modify). That is, the first element in the tuple is used when the depth=depthLimit. Of course, this works for any definition, not just "A". :-) See the Sierpenski Triangle in the test data for an example.
  5. Leave the print statements in the code. The online tests will look at those and compare them to see you are doing things correctly. I will run your programs by hand for full grading.
Several test curves are supplied.

Submission

Homework will be submitted as an uncompressed tar file that contains no subdirectories. The tar file is submitted to the class submission page. You can submit as many times as you like. The LAST file you submit BEFORE the deadline will be the one graded. Absolutely, no late papers. For all submissions you will receive email at your uidaho address showing how your file performed on the pre-grade tests. The grading program will use more extensive tests, so thoroughly test your program with inputs of your own. Your code should compile and run without runtime errors such as seg faults or Python errors. If it doesn't it is considered nearly ungradable.

If you have tests you really think are important or just cool please send them to me and I will consider adding them to the test suite.