Deprecated: Optional parameter $pophelp declared before required parameter $event is implicitly treated as a required parameter in /home/bradt/sites/blog.ipsin.org/textpattern/lib/txplib_html.php on line 1425
General error Warning: Cannot modify header information - headers already sent by (output started at /home/bradt/sites/blog.ipsin.org/textpattern/lib/txplib_html.php:1425) on line 4706
General error Warning: Cannot modify header information - headers already sent by (output started at /home/bradt/sites/blog.ipsin.org/textpattern/lib/txplib_html.php:1425) on line 5260
Lindenmayer Systems and the Logo Turtle | ipsin.org

Lindenmayer Systems and the Logo Turtle

Sep 21, 09:22 PM

Lindenmayer Systems, or L-Systems:

Take a string as a set of instructions in turtle graphics. “L” means “turn left”, “R” means “turn right”, and “F” means “go forward”.

Now imagine starting with a string “A” and a set of rules. You replace the characters in this string according to the rule a fixed number of times. Then for every type of character, you can either replace it with one of “L“, “R“ or “F“, or ignore/remove it.

For example, suppose you have one rule,

96591921c23058577c7ba692eb03065e10c57ba9

and a final rule

3c4e163f29ce067c46e787006814074720842f8f

In this example, it takes 12 d160e0986aca4714714a16f29ec605af90be704d or 12 06576556d1ad802f247cad11ae748be47b70cd9c turns to turn completely around.

We start with 6dcd4ce23d88e2ee9568ba546c007c63d9131c1b and apply the rule to get eb2626a337ecb1b4dce2ff92911b1ddba6bbc78a. We apply the rule again to get 2cbdbaba6b7e00b52a82c2bae22d96dad1b19e3c, and so forth. In my example, I stopped when I got a string that would have 5000 forward moves in it.

Here's what it looks like:

That’s one continuously traced path, all thanks to string rewriting. I’ve also created a page with a large number of random rules. It takes a lot of memory because of all the thumbnails, but if you’re curious about the rules used to generate a shape, simply follow the link to the SVG and “view source” to see what generated that shape.

---

Commenting is closed for this article.

---