Create a Lindenmayer System

What are L-systems?

Lindenmayer System are the geometric representation of formal grammars. Grammars themselves are sets of simple rules used to transform strings of characters. For example, here 4 rules are applied to the letter "a":

Rules [1] Transformation Sequence
1. cb > aa use 4.
2. aa > aba use 3. and 4.
3. b > c cba use 1. then 4.
4. a > baaa use 2.
a

Expressions generated by the grammar may be represented as geometric shapes if there are interpreted as instructions by a graphics plotter robot or "turtle":

Fmove forward, drawing a line
fmove forward without drawing a line
+turn left (by rotating clockwise on the spot)
-turn right (by rotating anti-clockwise on the spot)
[remember the current position
]return to the last remembered position

In this language the instruction "F+F+F+F" plot a square (if each turn is 90 degrees). Each straight line may then be transformed to a crooked line with the grammar rule "F" to "F+F-F-FF+F+F-F". After this transformation is repeated just a few times the square becomes a complex shape with fractal geometry (a "Koch island").

Astrid Lindenmayer was impressed by the complexity that emerges from a simple grammar like this. He believed these systems captured a mathematical principles of biological development. This is graphically illustrated by L-systems that generate fern and tree like patterns.


Try it yourself!

The program below allows you to generate 6 character "turtle" L-systems yourself. You can start by experimenting with the examples [2]. Once your ready to try your own L-system, follow these steps:

  1. Press the Clear button to reset everything
  2. Enter the initial bearing of the turtle (the direction it points in to start with) and the size of its turning angle in the Bearing and Rotate boxes.
  3. Enter the initial instruction sequence for the turtle in the Seed box.
  4. Press the Re-seed button to check the look of your initial sequence. If your input was understood you will see a new shape appear.
  5. Enter the two parts for each of your rules in the From and To boxes, pressing the Add Rule button to update your grammar.
  6. Complex shapes should then be generated by pressing the Transform button, which changes your seed into instructions for new shapes according to your rules.

There is lots of information about Lindenmayer systems on the web [3](I used a site formerly at Sussex University). Please mail feedback and interesting L-systems you've found to me - this page may itself develop if you do - and thanks for visiting!



Footnotes:

[1] For this example and below longer rules are applied first. Also empty or repeated "from" parts to the rules are not allowed. Above the seed went through longer character strings before returning to the seed. Other rules and seeds may enter a cycle of transformations like this, or may determine the expression grows indefinitely (or becomes empty).Back.

[2] If you find a good system, mail the setup, seed and grammar to me so I can add to these examples.Back.

[3] Try searching for Richard Dawkins' Biomorphs, artificial life and fractals too. The Santa Fe institute are notable champions of artificial life.Back.


Home © 2001 Joe L-B