Skip to content

L-System Visualizer App Info

For the app itself, visit: https://micahtillman.com/lsviz

See also the FAQs page and the v. 2 release notes.

L-Systems

Replacement Rules

A Lindenmayer System (see here and here, for example) is a set of instructions for turning a sequence of symbols into another (usually longer) sequence of symbols. For example, an L-system might take the sequence “ABC” and turn it into “AABABC.”

How would it do this? Well the system would have three rules. The rule for “A” would be, “replace each ‘A’ you find with ‘AA’.” The rule for “B” would be, “replace each ‘B’ you find with ‘BAB’.” And the rule for “C” would be, “replace each ‘C’ you find with. . . just a ‘C’.”

What’s fun about L-systems, however, is that you can feed any result back into the system again, to get a new (usually even longer) result. This means L-systems are “recursive”; they are meant to be done over and over — to recur. (Contrast this with, say, a car factory. That kind of factory has inputs [pieces of metal and plastic and rubber] and outputs [complete cars]. But you can’t then put the cars through the factory to combine them into bigger cars. Car factories are not recursive.)

Each time the L-system is “run” and outputs a new string of symbols, we call it an “iteration.” So, our first iteration turns “ABC” into “AABABC,” and our second iteration will turn “AABABC” into “AAAABABAABABC.” And you can keep doing this, over and over again, iteration after iteration. If you’re super bored, or are a computer.

Interpretation Rules

The real fun with L-systems is that you get to interpret the resulting sequences of symbols however you want. Usually, however, we interpret the symbols as instructions for drawing figures. For example, maybe “A” means “draw a line going forward,” while perhaps “B” means “turn left.” And maybe “C” means “turn right.”

The rules, of course, are arbitrary — both the replacement rules and the interpretation rules. So, the work of a Fractal Hunter(TM) boils down to trying to find sets of rules that produce visually-interesting results.

Summary

An L-system has three parts: (1) a start symbol (or sequence of symbols), which I will call its “seed,” (2) a rule for each symbol that says what other symbols to replace the symbol with, and (3) a rule for each symbol saying how to interpret it. Each time the system (a) reads through the current string of symbols, (b) applies its replacement rules to each symbol in the current string, and then (c) interprets the resulting (usually longer), is called an “iteration.”

L-Systems and Fractals

Some combinations of seeds and rules create figures that are clearly fractals. Even now, I am unable to predict which ones will and which won’t, however. My initial thesis was that the systems had to contain symmetry.

For example, perhaps the replacement rule for “A” could be “AcBcA,” which is a palindrome. Or perhaps the replacement rule for “F” should be something like “FrFlG,” while the replacement rule for “G” could be “GlFrF.” That would make the two rules mirrors of each other. Or perhaps the replacement rule for “G” should be “FrGlG,” which would be like the rule for “F” but both mirrored and “flipped.”

But then I keep stumbling across L-systems that generate fractals and yet don’t seem to have any symmetry in their rules. And a square is quite symmetrical as a figure, but isn’t a fractal.

So who knows?

The LSViz App

The L-System Visualizer App can be found here: https://micahtillman.com/lsviz

With it, you can explore L-systems that generate fractals, or other interesting figures. It is currently pre-programmed with over 200 fractals and fractal variants. You can either browse through these fractals, or have the app pick fractals at random to show you.

Feel free to look through those fractals and see if you can discern any patterns in the L-systems that generate them!

And, even better, feel free to create your own L-systems, and see what sorts of figures they generate!

Replacement Rules

If you’re trying to generate a fractal, I have had the most success with having each letter be replaced with at least one copy of itself — in addition to other letters. So, for example, the symbols with which “F” gets replaced should probably themselves contain an “F” — perhaps something like “Fr” or “rFrFr” or “FGFFFGF.”

That being said, do feel free to play around with the possibilities! Perhaps the replacement rule for one of the letters in your L-system should be left blank, so that the letter actually gets erased. That may turn out to be key to generating an undiscovered family of fractals!

Interpretation Rules

The L-System Visalizer App gives you two basic ways of interpreting symbols. Each symbol can be treated either as instruction to move (forward or backward), or as instruction to turn (left or right). Each move forward or backward can be accompanied by drawing a line, by drawing a dot, or both.

The colors used for the dots represent the iteration at which they appeared in the figure. Dots drawn at the very beginning will be red. Dots drawn in the next iteration will be orange. The next iteration will produce dots that are yellow. Then green. Then blue. Then purple. Then magenta.

How much difference there is between the colors produced by one iteration and the next depends on how many iterations you have asked the app to run. The more iterations, the more “finely chopped” the color wheel becomes/the finer the gradation becomes. See the FAQs page for more info on all this.

Furthermore, you can decide how much you want to turn left or right when setting up an L-system. When hunting for fractals, I have found the most success with angles in two different families: I often find that when I try a multiple of 30, or a multiple of 45, I get interesting results. In fact, sometimes an L-system that produces an interesting figure — but not a fractal — using one multiple of 30 as its angle will produce a fractal when using a different multiple of 30 (or a multiple of 45 instead).

Finally, there’s no reason you have to use only one symbol to mean “move” or one to mean “turn.” For example, the L-system that produces the Dragon Curve uses “F” and “G” to both mean “move forward,” while “l” means “turn left” and “r” means “turn right. And while the Dragon Curve uses 90-degree angles for both left and right turns, other fractals use different angles (e.g., 60 for left turns and 150 for right turns). Doing so can effectively introduce a third, implicit angle (since a 60-degree turn to the right, followed by a 150-degree to the left, results in basically a 90-degree turn).

See, once again, the FAQs page for more info.