Class LSystem

java.lang.Object
org.episteme.natural.biology.lsystems.LSystem

public class LSystem extends Object
Lindenmayer System (L-System) for generating fractal and plant-like structures.

L-systems are parallel rewriting systems used to model the growth of plants and other biological structures. They consist of:

  • Alphabet - set of symbols
  • Axiom - initial state
  • Production rules - symbol replacement rules

Since:
1.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
  • Constructor Details

    • LSystem

      public LSystem(String axiom, double angle)
      Creates a new L-System.
      Parameters:
      axiom - the initial string
      angle - the turning angle in degrees
  • Method Details

    • addRule

      public LSystem addRule(char symbol, String replacement)
      Adds a production rule.
      Parameters:
      symbol - the symbol to replace
      replacement - the replacement string
    • generate

      public String generate(int iterations)
      Generates the L-system string after n iterations.
      Parameters:
      iterations - number of iterations
      Returns:
      the generated string
    • getAxiom

      public String getAxiom()
    • getAngle

      public double getAngle()
    • getRules

      public Map<Character, String> getRules()
    • interpret

      public List<TurtleCommand> interpret(String lstring)
      Interprets the L-system string as turtle graphics commands.

      Standard symbols:

      • F - move forward and draw
      • f - move forward without drawing
      • + - turn left by angle (Yaw)
      • - - turn right by angle (Yaw)
      • invalid input: '&' - pitch down by angle
      • ^ - pitch up by angle
      • / - roll right by angle
      • \ - roll left by angle
      • | - turn around (180 degrees)
      • [ - push state (position, orientation)
      • ] - pop state