CPSC 120 Principles of Computer Science Fall 2025

Topics: L-Systems

Due: Fri 12/5 11:59pm


Introduction

Topics showcase applications of the core concepts, in this case drawing functions and recursion.

Fractals are often used to describe natural things because, like many natural things, fractals have the property of self-similarity — which essentially means that you can zoom in as much as you want and will still see the same basic shape. Realistic modeling of nature is of particular interest in computer graphics.

In this lab, you'll create fractal plants using L-systems.

Successfully completing this topic means that you are able to:


Handin

To hand in your sketches:


Policies

Like labs, topics are individual assignments — what you hand in must be your own work, your own ideas, your own effort. You may get help in office hours and from Teaching Fellows, but you may not work together with a partner or in a group with others to create solutions or write code.

The policies on late work and extensions, academic integrity, and the use of AI for topics are the same as for lab 2. Review the policies there. One extension token is needed for revise-and-resubmit without an initial handin.

Also review assignments and evaluation on the Policies page for how topics factor into the final grade. The short version: topics are optional for a passing grade (C-), but achieving proficiency for at least some topics is required for a higher grade.


Preliminaries

Reference

Review the slides, examples, and in-class exercises from 11/21 for more about L-systems and implementing L-systems in Processing.


Exercises

Fractal Plants

Fractal Plants

L-systems were introduced in class as a way of describing certain kinds of fractal shapes, such as plants. Several examples of plant L-systems are given below.

 
angle 25.7 degrees 20 degrees 20 degrees 25.7 degrees 22.5 degrees
generator F F X X X
production rule(s) F → F[+F]F[-F]F F → F[+F]F[-F][F] X → F[+X]F[-X]+X
F → FF
X → F[+X][-X]FX
F → FF
X → F-[[X]+X]+F[+FX]-X
F → FF

You may get a mirror image of the picture shown — that's OK. (It's a result of different interpretations of whether a positive angle corresponds to a right or left turn.)

Additional specifications:

Implementation notes:

Extra Credit

You can earn extra credit by going substantially beyond the required elements. If you do extra credit, save a copy of one of your plant sketches with the name lsys_ec as a starting point, then modify the copy — don't change your original sketches.

Some possibilities: