NetLogo banner

NetLogo Publications
Contact Us

Modeling Commons

Beginners Interactive NetLogo Dictionary (BIND)
NetLogo Dictionary

User Manuals:
Farsi / Persian


NetLogo Models Library:
Sample Models/Mathematics/Fractals

(back to the library)

L-System Fractals

[screen shot]

If you download the NetLogo application, this model is included. You can also Try running it in NetLogo Web


This program draws special types of pictures called fractals. A fractal is a shape that is self-similar --- that is, it looks the same no matter how closely you zoom in or out For instance, a tree can be thought of as a fractal since if you look at the tree as a whole, you see a stick, that is to say the trunk, with branches coming out of it. Then if you look at a smaller portion of it, say a branch, you see a similar thing, namely, a stick with branches coming out of it.

This model allows you to draw and look at one class of fractals, called L-system fractals. L-System fractals are made by following a set of rules over and over. The rules can be few, but a fascinating and complicated fractal can still form. By using different sets of rules, you can create a wide variety of different fractal designs.


In the beginning, there will be only one turtle for any fractal. Rules tell the turtle what to do. This turtle can do things such as draw a line, or turn to the right or left. This turtle can also split itself into two turtles. Each new turtle follows the same rules as the original turtle, and draws its own "branch" of the emerging fractal design.


Perhaps the best way to start with this program is by looking at examples of some L-system fractals. In the "Interface" tab, you will find a series of buttons: "Swirl", "Ball", etc. Each button sets up a different fractal. Some of these examples are famous fractals, such as Sierpinski's tree and Koch's snowflake. To view these examples, simply click on one of the example buttons and then press the GO ONCE button repeatedly.

You can also press GO and leave it pressed instead of pressing GO ONCE repeatedly. Watch the number of turtles though (in the COUNT TURTLES monitor). If it becomes very large the model may become very slow.

If you don't like the location of the fractal in the world you can change it by modifying the value of the following sliders: - INIT-X sets the initial x coordinate of the first turtle. It changes the horizontal starting location of the original turtle. - INIT-Y sets the initial y coordinate of the first turtle. It changes the vertical starting location of the original turtle.

If you don't like the color scheme of the fractal you can change it by modifying the value of the following sliders: - INIT-COLOR controls the initial color of the first turtle. - The value of COLOR-INC is added to the turtles color anytime a new turtle hatches.

The example buttons and the SETUP button choose the rules for a fractal. Each of the example buttons sets up the world to draw the fractal of the same name. The SETUP button sets up the world for drawing the rules found in the applyRules procedure in the Code tab.


Notice the self-similarity of the fractals at each iteration. What if one were to perform an infinite number of iterations? Would looking at any piece up close look any different than looking at the whole? Also notice how the number of turtles in each of the example is multiplied by some number at each iteration. Does this make sense? Try to figure out the number of turtles at some arbitrary step n for one or more of the examples.


Now that you have played around with settings for the examples provided, why not try making your own fractals. You can do this by changing the commands in the apply-rules procedure in the Code tab. The comments in that procedure list the commands you can use.


Try adding switches such as increment-by-random-length or decrement-by-random-degree that could impose a random factor to the movement of the turtles. Then add to the forward and turning functions, for example, a random value to the number of steps and degrees. This would increase the realism in a fractal.

Pick up a book on fractals or search on the internet to find fractals that are interesting and try to create them using the rules of L-system fractals. You may find some resources below.

Try extending the set of rules so that there are more than the basic ones included in this model. Then use these rules to make new fractals.

Try starting with more than just one turtle, in a different location or heading, and see how that can affect the fractals that you have made. Does it ruin them or does it make them more interesting and complex?


The hatch command is used to make an exact duplicate of an existing turtle.

The run command is used to run the current rule set.


all of the other models in the Fractals section of the Models Library (under Mathematics)


You may find more information on L-System fractals in the following locations:

This site offers some explanation and quite a few classic examples of L-systems.

This site offers an introduction to fractals, including L-system fractals as well as others:

The Fractal Geometry of Nature by Benoit Mandelbrot


If you mention this model or the NetLogo software in a publication, we ask that you include the citations below.

For the model itself:

Please cite the NetLogo software as:


Copyright 2001 Uri Wilensky.


This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at

This model was created as part of the projects: PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN CLASSROOMS and/or INTEGRATED SIMULATION AND MODELING ENVIRONMENT. The project gratefully acknowledges the support of the National Science Foundation (REPP & ROLE programs) -- grant numbers REC #9814682 and REC-0126227.

(back to the NetLogo Models Library)