CompSci 307
Fall 2021
Software Design and Implementation

OOLALA: L- System Visualizer

This language is a simplified version of the one invented by Aristid Lindenmayer at the University of Utrecht that has been used to model the growth processes of plant development.

Create an interactive visualizer for L-systems, short for "Lindenmayer's system". that supports users to write basic sets of rules to generate recursive drawings.

L-systems are rules and symbols that model growth processes as shapes that are self-similar on different scales, because growth involves repetition of the same simple process (e.g. branching). They consist of an starting string (e.g., a simple string like F), a set of production rules (e.g., F-F++F-F), and an alphabet of symbols which have some predefined meaning (e.g., F means mane the turtle go forward 10 pixels with its pen down). The starting string is recursively expanded a fixed number of times according to the rules, after which a long string is generated. By increasing the expansion level the form slowly grows, becoming more complex (this is what makes fractal forms so easy to describe).

In addition to the UI features common to all applications, it should all allow the user to:

Example

This is an example of a typical program:

Program Expansion Output
# Koch Snowflake
start F
rule F F-F++F-F

level 0: F
level 1: F-F++F-F
level 2: F-F++F-F-F-F++F-F++F-F++F-F-F-F++F-F
level 3: F-F++F-F-F-F++F-F++F-F++F-F-F-F++F-F-F-F++F-F-F-F++F-F++F-F++F-F-F-F++F-F++F-F++F-F-F-F++F-F++F-F++F-F-F-F++F-F-F-F++F-F-F-F++F-F++F-F++F-F-F-F++F-F

More examples are given here, but you are expected to make your own example files as well (including ones with syntactically incorrect programs).

Programs

The characters in the expanded string are evaluated using Turtle graphics to provide a geometrical interpretation to make their dynamics visible. Traditionally, F means to go forward (drawing a line from the current point to the next point), while + and - mean to turn (right or left). Thus, using just a few rules, it is possible to construct very complex and interesting fractals. Thus, for level 1 of the example above, your program could run the following commands (assuming the length has been set to 10 and the angle has been set to 30):

fd 10 lt 30 fd 10 rt 30 rt 30 fd 10 lt 30 fd 10
Note, the turtle should not be seen during the drawing.
Commands
Name Description
START symbol Set given symbol as the start of the program
RULE symbol string Describe how the given symbol expands when evaluated in a program string
SET symbol "Logo Commands" Define the Logo commands used to display the given symbol
Built-in Alphabet
Name Logo Commands
F PD FD length
G PU FD length
A PU BK length
B PD BK length
+ RT angle
- LT angle
X STAMP

General notes about a program's syntax:

Resources

Experiment with L-Systems interactively.

Learn more about how algorithmic biology and other uses of L-Systems: