Homework #5:

  1. A program, lsystem.py, was created so that it read a string from a file. The function drawShapes() was added to the file. Operations for new characters F, +, and - were added to the function. The file "system file" was entered into the program. The program read the file and produced scene5A.png. New operations were added to drawShapes() so that position and heading could be stored and restored. The pop() method was used to return the turtle to its proper location and heading. The file "systemB" was entered into the program to create a tree. L-systems from the algorithmic botany site were used and modified to create more tree scenes.
  2. To store and restore the turtle state, the command "append" was used. The heading and the position were appended, or attached to memory. These pieces of data were stacked, and then unstacked in the opposite order using the "pop" command. Pop() reads the data in the opposite order in which they were stacked.
  3. This image is scene5A. The L-system is shown beside the image.
  4. This image is scene5B using an L-system from ABOP. The L-system is shown beside the image.
  5. This image is scene5C, a modified L-system including leaves. The L-system is shown beside the image.
  6. Extensions: Below are scene5D and scene5E. scene5d is extension 2: create L-system to make an interesting picture. scene5E is extension 3: add colors or shapes to the L-system rules. Here, I added a red circle to make a modified tree L-system look like an apple tree. The L-systems are beside the images.