Skip to content
ExtendedSource checked

L-System

Generates structures by repeatedly rewriting symbols with grammar rules.

Quick Facts

Compact metadata for implementation and discovery.

Category
Procedural Generation
Difficulty
Beginner
Family
Grammar Generation
Tier
Extended
Status
Verified
Review
Source Checked
Sources
1
Formulas
0
Relationships
5
Code example
Not ready
Visualization
Ready
Aliases
Lindenmayer System

Overview

An L-System starts with an axiom string and applies production rules over several generations, often drawing the result with turtle graphics.

Core Concepts

generated structuresymbol rewritingmulti-scale detailgrammar generationseeded variationrule expansionspatial structure

Quick facts

Complexity

Runtime and memory behavior at a glance.

Best

O(n)

Average

O(n g)

Worst

O(n g)

Space

O(n)

When to Use

  • Use L-System when you need to rewrite symbols in parallel.
  • Use it for plant generation with inputs like axiom.
  • Use it when repeatable content can be produced from compact rules, parameters, and seeds.
  • Use it when the Grammar Generation tradeoff is acceptable for the problem size.

When Not to Use

  • Avoid it when authored control matters more than variation or replayability.
  • Avoid it when the required output is not generated symbol string or geometry.

What It Does

  • Rewrites symbols in parallel
  • Interprets the final string as structure or drawing commands

Use Cases

  • Plant generation
  • Fractal curves
  • Rule-based patterns

Inputs

  • Axiom
  • Production rules
  • Iteration count

Outputs

  • Generated symbol string or geometry

Pseudocode

  1. 1.Start with the axiom string
  2. 2.For each generation, replace every symbol using production rules
  3. 3.Keep symbols without rules unchanged
  4. 4.After the final generation, interpret symbols as drawing commands
  5. 5.Return the generated structure

Canonical Example

Input
axiom = 'F', rule = F -> F+F, iterations = 2
Output
string = 'F+F+F+F'
Explanation
L-System: The L-System rewrites each F in parallel for each generation.

Implementation Notes

  • Keep the input contract explicit: Axiom; Production rules; Iteration count.
  • Use this step as the implementation spine: Start with the axiom string.
  • Then preserve the next state change: For each generation, replace every symbol using production rules.
  • Expose seed and parameters so results can be reproduced and tuned.

Common Pitfalls

  • Small rule changes can produce very different structures.
  • Letting random choices create disconnected, invalid, or impossible-to-use output.
  • Returning generated symbol string or geometry without handling empty, invalid, or boundary inputs.

Interactive Mechanism Walkthrough

Spatial Primitive & Sweep-Line Canvas

Show symbols expanding into branching plant-like geometry.

L-System mechanism walkthrough step 1 of 5
Step 1 of 5: Start with the axiom string
grammar-growth

Notes

L-System operates in O(n g) time and O(n) space within the Grammar Generation family. Often compared with Recursive Descent Parsing and Domain Warping.

Sources (1)

What each reference supports for this entry.

The Algorithmic Beauty of Plants

Book

Reference for L-system rewriting rules and plant-like procedural structures.

Open source

Explore Next

Good next jumps from the relationship graph, ranked for useful discovery.

L-systems use rewriting rules for recursive structures.

Conceptual neighborSpace Colonization Algorithm

Both are common procedural plant or branching structure methods.

Tags

Procedural GenerationGrammar GenerationFractal