Beginners Interactive NetLogo Dictionary (BIND)
Farsi / Persian
NetLogo Models Library:
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 RIGHT-CIRCLE function, then the LEFT-CIRCLE 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 NUM-TURTLES 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. PATTERN-3 and PATTERN-5 are probably the simplest patterns in this model in terms of explaining their behavior. Basically, PATTERN-3 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 NINE-GON function and then dies. All the other turtles turn left by 1 degree and then hatch a turtle that performs the LEFT-CIRCLE function and then dies.
Every turtle hatches another turtle that performs the LEFT-SQUARE function and then dies.
Every turtle moves forward DIRECTION steps and then hatches a turtle which performs the following functions in the following order: NINE-GON, OCTAGON, RIGHT-CIRCLE, PENTAGON, HEXAGON, and LEFT-CIRCLE. After performing these functions, each hatched turtle then dies.
Set NUM-TURTLES to a desired value between 0 and 36 (default value is 10). NUM-TURTLES determines how many initial turtles you want to start out with. These initial turtles will spawn other shape-making turtles.
Set COLOR-SEP to a desired value between 0 and 30 (default value is 2). COLOR-SEP determines the range of colors that the turtles (and hence the kaleidoscope) will take on. The higher the value, the smaller the range.
Set MAX-NUM to a desired value between 1024 and 8192 (default value is 4096). MAX-NUM 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 COLOR-SEP and NUM-TURTLES, press the SETUP button to set-up 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 PATTERN-2, PATTERN-4 or PATTERN-6. PATTERN-1, PATTERN-3, and PATTERN-5, 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 info-window.
The slider DIRECTION (default value is 2) is designed for PATTERN-1 and PATTERN-3. At each cycle, DIRECTION determines the amount that the pattern-making 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 PATTERN-5, 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 COLOR-SHIFT button will continuously increase or decrease the value of 'curr-color-sep' by a small random amount. Thus the slider value itself isn't changed, but the color value of the turtle is. The SHIFT-DIRECTION chooser determines if 'curr-color-sep' is increased or decreased.
Other features of the model are the LIFT-PEN and RESTORE buttons. LIFT-PEN lifts the pen on all turtles and kills all turtles greater than NUM-TURTLES. RESTORE kills all turtles greater than NUM-TURTLES and tells all turtles to put their pen down. Killing all turtles greater than NUM-TURTLES restores the original number of turtles in the world.
A useful tool that can be used in conjunction with the LIFT-PEN and RESTORE buttons is a switch called FOLLOW-TURTLE. When you press LIFT-PEN without FOLLOW-TURTLE 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. COUNT-TURTLES displays the current number of turtles in the world. Likewise, CURR-COLOR-SEP 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 COUNT-TURTLES. Right away, it becomes much larger than NUM-TURTLES, but quickly settles on some nice big number. Take a look at the CODE tab. Initially, upon setup, there are NUM-TURTLES 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 NUM-TURTLES is exploding into a number much larger than NUM-TURTLES 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 NUM-TURTLES 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 COLOR-SEP (known in the code as 'current-color-sep') alters the appearance of the pattern. Turn COLOR-SHIFT on, and let 'current-color-sep' 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 PATTERN-1 AND PATTERN-3 and the EXPANDER slider on PATTERN-5. Observe what happens to the pattern as you change the values of each. GEOMETRON-TOP-DOWN is meant to be a visually pleasing model just to watch. See what different values of COLOR-SEP produce, and explore how COLOR-SHIFT 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 curr-color-sep from COLOR-SHIFT). 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 NUM-TURTLES and then stop the pattern and push CLEAR-PATCHES-LIFT-PEN. Then start the pattern again. What happens? Can you explain why this happens?
Try changing the MAX-NUM slider during a run, what happens? Can you explain why this occurs?
Whenever a turtle is hatched by one of NUM-TURTLES, 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 GEOMETRON-TOP-DOWN project. In the current project, turtles spin off from a center core of NUM-TURTLES turtles. In your new project, maybe the drawing turtles could orbit around some fixed (or moving) point-look at the NetLogo projects 'n-bodies' and 'gravitation'.
GEOMETRON-TOP-DOWN 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 variable-there'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, pattern-1 utilizes the right-shape and left-shape 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 pattern-1. 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 RIGHT-CIRCLE: 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 LEFT-CIRCLE: 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 LEFT-SQUARE: 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 RIGHT-TRIANGLE: 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 NINE-GON: 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 nine-gon 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 pattern-1, the fact that each hatching turtle moves 0.5 steps forward means that the resulting shape from the RIGHT-CIRCLE OR LEFT-CIRCLE function will resemble a kidney bean rather than a circle, which is what the RIGHT-CIRCLE and LEFT-CIRCLE 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 pattern-1, 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 Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/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 firstname.lastname@example.org.
This model was created as part of the project: CONNECTED MATHEMATICS: MAKING SENSE OF COMPLEX PHENOMENA THROUGH BUILDING OBJECT-BASED 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: 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. Converted from StarLogoT to NetLogo, 2001.