Preston Decker's Fifth CS151 Homework Preston Decker's Fifth CS151 Homework

Explanations

  • 1.Our task was to use L systems to create shapes, eventually leading to the creation of a tree.
  • 2. The turtle is stored through the mem.append lines in the code, modifying position and heading respectively. Essentially, these save the last position before each turtle movement type. The turtle state is restored through the setheading mem.pop and goto mem.pop parts of the code, which tell the turtle to return to the last state before the state it was just in if the turtle has reached the end of a branch. It is also worth noting that for either of these to work it was first necessary to give mem the empty list at the beginning of the code. As far as my color goes, this may have been rather unusual, but I created another character, 'R' and added this immediatley after the leaf command in the L string. All R did was to reset colors to 0.0 and go forward by 0, which of course ultimately did nothing other than set color back to black. One of my classmates helped suggest this.

    3. Image One L String

    F-F-F-F

    F

    FF-F+F-F-FF

    3

    5

    90

    Image two L String

    F

    F

    FFF-[-F+F+F]+[+F-F-F-]

    4

    5

    27.0

    Image three L String

    F

    F

    FF-[-F+F+F]+[+F-F-F-L-R]

    4

    5

    27.0

    I need to thank Mac Simpson and Robyn Daley for help with last weeks project, which supplied code for this weeks and a few other classmates for help with this week's part as well.