Home Download Help Resources Extensions FAQ NetLogo Publications Contact Us Donate Models: Library Community Modeling Commons Beginners Interactive NetLogo Dictionary (BIND) NetLogo Dictionary User Manuals: Web Printable Chinese Czech Farsi / Persian Japanese Spanish

NetLogo Models Library: 
If you download the NetLogo application, this model is included. You can also Try running it in NetLogo Web 
This model uses turtles to repeatedly draw circles and other geometric shapes, while turning periodically resulting in complex patterns that look like kaleidoscopes and pinwheels. It demonstrates how even simple rules can create complex and beautiful patterns.
In this pattern, every 10th turtle moves forward 0.5 steps and to the right by DIRECTION degrees. Each call to the pattern hatches a turtle who performs the RIGHTCIRCLE function, then the LEFTCIRCLE function and then dies. By increasing the DIRECTION, the turtles increase the degrees by which they turn to the right. This means that at each forward movement the turtle turns tighter around a center point. Thus, when DIRECTION is set to 0, the turtle simply moves forward. The more it is increased, say from 0 to 1 to 2 to 10, the more circular the turtles movement becomes. Although the pattern changes, it must be understood that the underlying shape that is being created is a circle.
Every even numbered turtle moves forward 1 step and turns right by 1 degree. It then hatches a turtle that performs the HEXAGON function and then dies. Every odd numbered turtle moves forward 1 step and turns left by 1 degree. It then hatches a turtle that performs the OCTAGON function and then dies. It is interesting to note that when the NUMTURTLES slider is raised to a high number ,i.e., greater than or equal to 20, the pattern in the lower numbers becomes unrecognizable. However, it must be understood that although the new pattern may appear to be different, still, the underlying shapes that are being made are the hexagon and octagon.
Every 5th turtle moves forward 0.5 steps and turns right by DIRECTION degrees. It then hatches a turtle which performs the PENTAGON function and then dies. PATTERN3 and PATTERN5 are probably the simplest patterns in this model in terms of explaining their behavior. Basically, PATTERN3 creates pentagons, but because the turtles move forward 0.5 and move to the right DIRECTION number of degrees, this is what causes the pattern to drastically change. The illusion is that the hatched turtles are somehow creating different shapes but the truth of the matter is that they are making pentagons and always will be making pentagons. It is only the slight variations in outside influences that brings about a change in the pattern.
Every 3rd turtle turns right by 1 degree and then hatches a turtle that performs the NINEGON function and then dies. All the other turtles turn left by 1 degree and then hatch a turtle that performs the LEFTCIRCLE function and then dies.
Every turtle hatches another turtle that performs the LEFTSQUARE function and then dies.
Every turtle moves forward DIRECTION steps and then hatches a turtle which performs the following functions in the following order: NINEGON, OCTAGON, RIGHTCIRCLE, PENTAGON, HEXAGON, and LEFTCIRCLE. After performing these functions, each hatched turtle then dies.
Set NUMTURTLES to a desired value between 0 and 36 (default value is 10). NUMTURTLES determines how many initial turtles you want to start out with. These initial turtles will spawn other shapemaking turtles.
Set COLORSEP to a desired value between 0 and 30 (default value is 2). COLORSEP determines the range of colors that the turtles (and hence the kaleidoscope) will take on. The higher the value, the smaller the range.
Set MAXNUM to a desired value between 1024 and 8192 (default value is 4096). MAXNUM determines the maximum number of turtles that can be in the world at any time. Note however, a higher value will make the model run slower.
When you have set COLORSEP and NUMTURTLES, press the SETUP button to setup the model.
Next, choose a pattern. In each pattern, the initial turtles hatch other turtles and those hatched turtles draw different geometric shapes. Each pattern is represented by a forever button. The user cannot change PATTERN2, PATTERN4 or PATTERN6. PATTERN1, PATTERN3, and PATTERN5, however, allow for user control using the DIRECTION and EXPANDER sliders. For detailed descriptions of the instructions in each pattern, go to the end of the infowindow.
The slider DIRECTION (default value is 2) is designed for PATTERN1 and PATTERN3. At each cycle, DIRECTION determines the amount that the patternmaking turtles turn to the right. In other words, if DIRECTION is set to 12, each turtle will turn 12 degrees to the right before moving forward.
The slider EXPANDER is designed specifically for pattern 5 (default value is 80). At each cycle of PATTERN5, EXPANDER determines how large each leg of the polygon will be.
The user also has control over the color distribution exhibited by each pattern. The COLORSHIFT button will continuously increase or decrease the value of 'currcolorsep' by a small random amount. Thus the slider value itself isn't changed, but the color value of the turtle is. The SHIFTDIRECTION chooser determines if 'currcolorsep' is increased or decreased.
Other features of the model are the LIFTPEN and RESTORE buttons. LIFTPEN lifts the pen on all turtles and kills all turtles greater than NUMTURTLES. RESTORE kills all turtles greater than NUMTURTLES and tells all turtles to put their pen down. Killing all turtles greater than NUMTURTLES restores the original number of turtles in the world.
A useful tool that can be used in conjunction with the LIFTPEN and RESTORE buttons is a switch called FOLLOWTURTLE. When you press LIFTPEN without FOLLOWTURTLE being on, you see the skeleton of the pattern since the turtles are moving without their pen down. But when the switch is turned on, one hatched turtle will put its pen down. However, since turtles are constantly being born and dying it may take time for this particular turtle to appear. It should also be understood that because some of the patterns divide the turtles into different groups and assign them different shapes to create, more than one turtle may be told to put its pen down in order to represent what all the turtles in the pattern are doing.
Two monitors are provided at the bottom of the Interface Window. COUNTTURTLES displays the current number of turtles in the world. Likewise, CURRCOLORSEP displays that variable's value, so that you know when it has been altered, and by how much.
An important thing to notice here is the number given in COUNTTURTLES. Right away, it becomes much larger than NUMTURTLES, but quickly settles on some nice big number. Take a look at the CODE tab. Initially, upon setup, there are NUMTURTLES turtles. Once one of the pattern buttons is pressed, each of these turtles repeatedly hatches a new turtle and turns by a specified degree.
It is important to understand that this phenomenon, the fact that initial NUMTURTLES is exploding into a number much larger than NUMTURTLES is because other turtles are being hatched in between the time a single turtle is hatched and the time it finishes drawing its given shape. Thus, if we were to add a wait
statement into one of the patterns, not as many turtles could be hatched. In other words, the number of turtles greater than NUMTURTLES would decrease. As turtles execute their commands much quicker than the hatched turtles, they produce many turtles during one loop of a pattern; eventually, though, turtles start to die off. At this point, the number of turtles who are born is roughly equal to the number who die at any given step.
You also should notice how COLORSEP (known in the code as 'currentcolorsep') alters the appearance of the pattern. Turn COLORSHIFT on, and let 'currentcolorsep' become very large. Then watch what happens when it is small, maybe zero or some negative number.
Try playing around with the DIRECTION slider on PATTERN1 AND PATTERN3 and the EXPANDER slider on PATTERN5. Observe what happens to the pattern as you change the values of each. GEOMETRONTOPDOWN is meant to be a visually pleasing model just to watch. See what different values of COLORSEP produce, and explore how COLORSHIFT changes the appearance of the kaleidoscope. What seems the best to you?
Try changing the code in the Code tab. Increase the size of the shapes drawn by each of the turtles, or try changing the size of the angle each of the turtles turns through.
Instead of each turtle moving or turning a given amount, what about having it move a small random amount (as in the changes to currcolorsep from COLORSHIFT). How much randomness can you add to 'kaleidoscope' and still maintain some kind of overall structure?
After running one of the patterns, try changing the number of NUMTURTLES and then stop the pattern and push CLEARPATCHESLIFTPEN. Then start the pattern again. What happens? Can you explain why this happens?
Try changing the MAXNUM slider during a run, what happens? Can you explain why this occurs?
Whenever a turtle is hatched by one of NUMTURTLES, it proceeds to draw a certain pattern. Change the commands in hatch
so that the turtle draws some other shape or pattern. Try to predict what overall shape will emerge.
Try to write an entirely new kind of GEOMETRONTOPDOWN project. In the current project, turtles spin off from a center core of NUMTURTLES turtles. In your new project, maybe the drawing turtles could orbit around some fixed (or moving) pointlook at the NetLogo projects 'nbodies' and 'gravitation'.
GEOMETRONTOPDOWN makes nice use of the turtle primitive hatch
. Whenever a turtle is hatched, it executes the command list that follows the hatch
command. Generally all it does is change its color or alter some variablethere's no reason it can't run some other, possibly lengthy, procedure. Which is exactly what happens here.
This model is one of the rare models in the NetLogo Models Library that uses the "continous" display update mode. This is because this model does not have a concept of ticks
since each turtle is following a set of rules in parallel.
The following is a list of all the basic shape functions that are used in this model to create the six patterns. It is important to understand that the complexity of the patterns are actually nothing more than different combinations of these shape functions. For example, pattern1 utilizes the rightshape and leftshape functions. Both these functions simply draw circles. However, by adding slight variations to what the turtle does and which ones do it, it is possible to create the pattern that is represented by pattern1. This, in fact, is the basic algorithm that the model uses in order to create all the patterns. Take the basic shape functions, add slight variations to what the turtles do and choose which turtles do it.
about RIGHTCIRCLE: Performs the following procedure 180 times: Move forward 1.5 steps and turn right by 2 degrees. To see the shape that this function creates, try calling it in the command center with one turtle with the pen down. A turtle will create a circle heading in the right direction.
about LEFTCIRCLE: Performs the following procedure 180 times: Move forward 1.5 steps and turn left by 2 degrees. To see the shape that this function creates, try calling it in the command center with one turtle with the pen down. A turtle will create a circle heading in the left direction.
about LEFTSQUARE: Performs the following procedure 4 times: Move forward EXPANDER steps and turn right by 90 degrees. To see the shape that this function creates, try calling it in the command center with one turtle with the pen down. A turtle will create a square heading in the left direction.
about RIGHTTRIANGLE: Performs the following procedure 3 times: Move forward 35 steps and turn right by 120 degrees. To see the shape that this function creates, try calling it in the command center with one turtle with the pen down. A turtle will create a triangle heading in the right direction.
about OCTAGON: Performs the following procedure 8 times: Move forward 30 steps and turn right by 45 degrees. To see the shape that this function creates, try calling it in the command center with one turtle with the pen down. A turtle will create an octagon heading in the right direction.
about PENTAGON: Performs the following procedure 5 times: Move forward 35 steps and turn right by 72 degrees. To see the shape that this function creates, try calling it in the command center with one turtle with the pen down. A turtle will create a pentagon heading in the right direction.
about HEXAGON: Performs the following procedure 6 times: Move forward 30 steps and turn right by 60 degrees. To see the shape that this function creates, try calling it in the command center with one turtle with the pen down. A turtle will create a hexagon heading in the right direction.
about NINEGON: Performs the following procedure 9 times: Move forward 35 steps and turn right by 40 degrees. To see the shape that this function creates, try calling it in the command center with one turtle with the pen down. A turtle will create a ninegon heading in the right direction.
Notice that in each of these functions, the number of times the procedure is repeated multiplied by the number of degrees the turtle turns either to the right or to the left is equal to 360 degrees. Which means that each of the turtles is creating a polygon.
I discovered that in the patterns where the turtle moves a number of steps forward and then turns right or left in some direction, this action significantly changes the pattern. For example, in pattern1, the fact that each hatching turtle moves 0.5 steps forward means that the resulting shape from the RIGHTCIRCLE OR LEFTCIRCLE function will resemble a kidney bean rather than a circle, which is what the RIGHTCIRCLE and LEFTCIRCLE function are designed to produce.
It is important to understand that these patterns are able to be created because they obey certain basic rules about geometry. For example, I mentioned above that all the functions create polygons. This is due to the fact that every polygon must have the interior sum of its angles equal to 360 degrees. However, certain slight alterations like those mentioned above, are enough to change the shape and create a new one. For example, if the DIRECTION slider started off at 0 in pattern1, every hatching turtle would simply be moving forward by 0.5 steps as it was creating its pattern. However, if we increase the slider by increments of 0.1, we notice that its movements seem to be getting tighter and tighter until it remains fixed in one place and keeps revolving around a point.
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 1998 Uri Wilensky.
This work is licensed under the Creative Commons AttributionNonCommercialShareAlike 3.0 License. To view a copy of this license, visit https://creativecommons.org/licenses/byncsa/3.0/ 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 uri@northwestern.edu.
This model was created as part of the project: CONNECTED MATHEMATICS: MAKING SENSE OF COMPLEX PHENOMENA THROUGH BUILDING OBJECTBASED PARALLEL MODELS (OBPML). The project gratefully acknowledges the support of the National Science Foundation (Applications of Advanced Technologies Program)  grant numbers RED #9552950 and REC #9632612.
This model was converted to NetLogo as part of the projects: PARTICIPATORY SIMULATIONS: NETWORKBASED 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 REC0126227. Converted from StarLogoT to NetLogo, 2001.
(back to the NetLogo Models Library)