An L-system consists of:
- An alphabet of different strings (e.g.
"F","+","-"
) - Rules that specify how "letters" in the alphabet are replaced with other strings (e.g.
F -> F+F-F
) - An axiom which is the starting string upon which the rules act in successive iterations (e.g.
FF-F
)
In this program, we visualise the strings generated by subsequent iterations of the using turtle interpretation. The character F
instructs the turtle to move forward by 1 unit, +
rotates the turtle by X degrees and -
by rotates by -X degrees. This draws the L-system from the string. Branches are denoted by brackets []
and can be included in the rules to generate shapes with branching structures.
To visualise an L-system in this program:
- Add a rule set and define at least one rule using the characters in this alphabet at least once
"F","+","-","[","]"
. Other characters can be used too, but will not be interpreted by the turtle.- Rules contain a key and a value. During an iteration the value will replace the key.
- Set the number of iterations to a desired number - start lower as L-systems can very quickly become too large to compute in a reasonable timeframe.
- Define the branching angle X.
- Define the axiom.
- Select the rule set and the axiom and press generate.
Context sensitivity is where the string that replaces a "letter" depends on the surrounding letters. It is therefore a property of the rules of an L-system. To specify context sensitive rules, enter the rule key in this format "left-context<X>right-context"
. This will replace the letter X with the associated rule value only when X has left-context to the left and right-context to the right in the string. E.g. for the alphabet "F1","F0","+","-","[","]"
, the rule F0<F1>F0 -> +[F1F1]-F
means F1
is replaced by +[F1F1]-F
only when F0
is to the left and F1
is to the right.