Lindenmayer systems (L-systems) are a way of iterating on a grammar with an initial state and set of rules. The way that I have implemented L-systems are a little bit different than any others that I've seen, and it may be disparate enough that it isn't an L-system at all anymore, but I think it's a more explicit way to express the grammar.
My implementation of the L-system is made up of the following values:
Final string:
Suggested settings:
Preview | Axiom | Rules | Terminal Rules | Iterations | Link |
---|---|---|---|---|---|
IF-G-G | {"F": "F-G+F+G-F", "G": "GG"} | {"F": "MOV 1", "G": "MOV 1", "+": "ROT -120", "-": "ROT 120", "I": "ROT -90"} | 3 | Click to View | |
FX | {"X": "X+YF+", "Y": "-FX-Y"} | {"F": "MOV 1", "-": "ROT 90", "+": "ROT -90"} | 9 | Click to View | |
0 | {"1": "11", "0": "1[0]0"} | {"1": "MOV 1", "0": "MOV 1", "[": "PUSH,ROT -45", "]": "POP,ROT 45"} | 5 | Click to View | |
F--F--F | {"F": "F+F--F+F"} | {"F": "MOV 1", "-": "ROT -60", "+": "ROT 60"} | 3 | Click to View | |
IF | {"F": "F+F--F+F"} | {"F": "MOV 1", "-": "ROT -85", "+": "ROT 85", "I": "ROT -90"} | 5 | Click to View | |
IF | {"F": "+F--F+"} | {"F": "MOV 1", "+": "ROT 45", "-": "ROT -45", "I": "ROT 90"} | 10 | Click to View | |
W | {"W": "+++X--F--ZFX+", "X": "---W++F++YFW-", "Y": "+ZFX--F--Z+++", "Z": "-YFW++F++Y---"} | {"F": "MOV 1", "+": "ROT 30", "-": "ROT -30", "[": "PUSH", "]": "POP"} | 5 | Click to View | |
A | {"A": "A-B--B+A++AA+B-", "B": "+A-BB--B-A++A+B"} | {"A": "MOV 1", "B": "MOV 1", "+": "ROT 60", "-": "ROT -60"} | 3 | Click to View | |
F+F+F+F | {"F": "F+f-FF+F+FF+Ff+FF-f+FF-F-FF-Ff-FFF", "f": "ffffff"} | {"F": "MOV 1", "f": "PUT 1", "-":"ROT 90", "+": "ROT -90"} | 3 | Click to View | |
RF | {"F": "FF[[[+F]F]-F]"} | {"[": "PUSH", "]": "POP", "F": "MOV 1", "M": "MOV 1", "-": "ROT 90", "+": "ROT -90", "R": "ROT -45"} | 3 | Click to View | |
X | {"X": "F[-X][X]F[-X]+FX", "F": "FF"} | {"F": "MOV 1", "-": "ROT 25", "+": "ROT -25", "[": "PUSH", "]": "POP"} | 5 | Click to View | |
F | {"F": "1FF-[2-F+F+F]+[3+F-F-F]"} | {"F": "MOV 1", "-":"ROT 22.5", "+": "ROT -22.5", "[": "PUSH", "]": "POP", "1": "COL #000000", "2": "COL #00FF00", "3": "COL #77FF77"} | 3 | Click to View | |
F | {"F": "F[+F]F[-F][F]"} | {"F": "MOV 1", "-":"ROT 20", "+": "ROT -20", "[": "PUSH", "]": "POP"} | 3 | Click to View | |
F | {"F":"F-[F]-[F]-[F]"} | {"F":"MOV 1", "[":"PUSH", "]": "POP", "-": "ROT 120", "+": "ROT -120"} | 3 | Click to View | |
FX | {"X":"M[-FY]+FX", "Y":"FX+FY-FX"} | {"F":"MOV 1", "[":"PUSH", "]": "POP", "-": "ROT 30", "+": "ROT -30", "M": "MULT .6"} | 3 | Click to View | |
IX | {"X": "+FF-YFF+FF--FFFTXTF--YFFFYFFFT", "Y": "-FF+XFF-FF++FFFTYTF++XFFFXFFFT", "F": "GG", "G": "GG"} | {"F": "MOV 1", "G": "PUT 1", "-": "ROT -60", "+": "ROT 60", "I": "ROT -90", "T": "ROT -180"} | 3 | Click to View | |
[X]++[X]++[X]++[X]++[X] | {"W":"YF++ZF----XF[-YF----WF]++","X":"+YF--ZF[---WF--XF]+","Y":"-WF++XF[+++YF++ZF]-","Z":"--YF++++WF[+ZF++++XF]--XF","F":""} | {"F": "MOV 1", "-": "ROT -36", "+": "ROT 36", "[": "PUSH", "]":"POP"} | 2 | Click to View |