About Lsystems and Lparser ...


A Lsystem is a rule like description of a 3d form. It contains descriptions of parts and how they should be assembled together. The program reads a Lsystem description and processes it into a 3d form which can then be outputted in several formats. The description is applied to itself a number of times (recursion levels) so fractal and recursive forms are very easy to describe in a Lsystem. That's why they are used a lot for plants, trees and natural looking organic forms. By increasing the recursion level the form slowly grows and becomes more complex.

My implementation of a Lsystem parser (called Lparser) also allows mutations to take place during the growing of the form. These mutations can change the form slightly or quite dramatically. This allows you to create a form once and then create a whole series of forms all clearly descendant from the original Lsystem. Look for them in the gallery!

 

The implemented Lsystem is based on the one described in the book: The Algorithmic Beauty of Plants by P. Prusinkiewicz and A. Lindenmayer (this is where the L comes from). If you give me a book called the ALGOLRITHMIC BEAUTY… I am sold already!

 

If you want more information on making your own Lsystems you'll want to check out this book. A lot can be done by changing the Lsystems supplied with the Lparser and seeing for yourself what changes in the final form.

 

Download the Lparser package

 

Read the documentation

 

Lparser source code


Source code of the lparser is aslo available, for those who want to port or just play with new options. The code is straight, no frills ANSI-C with even less documentation but it should run on pretty much anything with a C or C++ compiler. My current job will leave me with neither the time nor the inclination to do serious code hacking so I'm throwing the code into the wind, hoping that it will germinate and produce lots of mutated offspring ! The Lparser source may be freely distributed. Just ask me for it and I will email it to you.

This example file creates the shell shape you see to the left:


recursion 38
angle 10
thickness10
axiom PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
rule P = S>(20)gg'
rule S = [&(90)[A]+(20)^(90)gg'&(90)[B][cD]]
rule D = ^FD          
rule
A = [^gA{.].     
rule
B = B^.g.}

 

Why the Lparser


It were books like The Blind Watchmaker that send me on the road looking for my own geometry generator to do genetic programming on 3d shapes. I had some experience with 2d L-systems/turtle graphics and this language seemed ideal to me to apply mutations too. Since I had an elaborate source and working knowledge of 3d graphics and vector manipulation, I decided that I would create a 3d Lsystem parser that would allow for mutation.  

After playing with first version of the program I started to distribute it using a local BBS, fidonet and later Internet (yes it is THAT old) as a freeware application to make trees and bushes. Since the L-systems language is quite hard to learn for a novice I supplied a large series of example Ls files to give the user something to start with.

 

Yet the product has a very steep learning curve. Although I have seen a sizeable number of people incorporate Lparser shapes into their images, only a few have actually explored the possibilities of the language. L-system rules are a very efficient coding system. I do like the idea that one can code a complete forest, no two trees being the same, detailed down to the single leave, in less than 100 bytes.

 

Genetic mutation


With the Lparser I explored all kinds off concepts like genetic drift and did a lot of the experiments mentioned in The Blind Watchmaker myself. It was very interesting to see the difference between mutation on the genotype level (using the -u option) and randomness introduced on the phenotype level (with the ~ command). Sometimes one would have a piece of the L-system being disabled during mutation runs and then suddenly be activated again. Leading to sudden shape changes in otherwise slowly developing forms.

The Lparser was made to be able to parse broken L-systems rules. Apart from the start parameters and the EOF marker one can feed it pretty much random characters and it will still function. This allows the mutation algorithm to be completely context free since it does not have to worry about destroying the integrity of the L-systems rules. Playing with mutation I discovered much the same effects as you will find described in the write ups of several genetic simulators.

 

As a modelling language and tool, the Lparser can create all kinds of organic shapes. I like the shapes best where you can see that they have an organic quality but you cannot make out if they are plant or animal. So there is something which we can identify as organic yet is independent of it being a specific animal or plant like life-form.

 

Examples


If you have a VRML plugin in your browser try clicking on the last three images to the left. You will get a lparser shape to move around, real time, in 3d! I use the Cortona plugin. You can find a number of animated Lparser shapes on YouTube. Try Flowers, Beker, Airhorse and Hold. Try Aexion or In Vitro for great images! 

 

 

 

 

lapre004004.jpg lapre004003.jpg lapre004002.jpg arrowleft.png