Game dev
Saved & recent

L-system

Also called: Lindenmayer system

Related terms: grammar, turtle graphics, procedural plants

A way to grow shapes by rewriting text. Start with a short string and replace each letter by a rule, again and again. Then read the result as drawing commands: F is go forward, + and - are turn, [ and ] are start and end a branch.

One short rule grows into a tree, a fern or a bolt of lightning. Games use it for plants and for road networks.

F becomes F[+F]F[-F]F

Further reading
Przemysław Prusinkiewicz and Aristid Lindenmayer: The Algorithmic Beauty of Plants
F → F[+F]F[−F]F rewrite 1 rewrite 2 rewrite 3
Starting from F, each rewrite replaces every F with F[+F]F[−F]F. The drawing turns 23° at each plus or minus sign.

View in the full Game dev collection