L-System test 1

Stochastic L-System with regular expressions and with 2D turtle graphics.

Turtle states:

rotation angle
angle in degrees. This value is used to modify the forward direction.
forward direction
angle in degrees
step size
step size, [1..]
stroke
stroke weight, [1..]

Turtle commands: (symbols)

F
draw forward one step
f
draw forward half a step
M
move forward one step
m
move forward half a step
+
rotate the turtle right by the angle from the current state
-
rotate the turtle left by the angle from the current state
S
multiply the stroke weight by 2
s
divide the stroke weight by 2
T
increase the stroke weight by 1
t
decrease the stroke weight by 1
D
multiply the step size by 2
d
divide the step size by 2
E
increase the step size by 1
e
decrease the step size by 1
^
push the turtle state to the stack
v
pop the turtle state from the stack

Production rule definition: (one line per rule)

[ selection probability, "ps:" ] ,
[ group probability, "pg:" ] ,
{ symbol } | regex ,
"->" ,
{ symbol | regex capture group }

Additional definitions: (one line per definition)

• "name: ", string
instance name, used for load/save as a unique identifier
• "matchLongest:", bool (* = true *)
if true and more than rule matches, favor the longest match(es)
• "randomSeed:", string (* = "0" *)
seed for the pseudo random number generator

Generally:

• Each rule has a "selection probability" which determines if it's considered at all.
• If more than one rule matches, a rule is selected randomly.
For that, all the "group probability" values are stacked in a sequence of intervals starting at zero.
A random value between zero and the the highest value is generated to select the matching interval and therefore the matching rule.
• Whitespaces are skipped.

Production rule definitions:

Increase the number of loops (#loops) and observe the Result string.

Additional definitions:

name: my L-System test
matchLongest: true
randomSeed: my random seed

Predefined systems:

Turtle parameters:
Step:
Angle:
L-System parameters:
#loops:
Storage:




L-System parameters:
Axiom:
Rules: (Attention: Predecessors are regular expressions. Escape accordingly.)
Result string: