# Geometron Top-Down

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)

## WHAT IS IT?

This model uses NetLogo turtles to repeatedly draw circles and other geometric shapes, turning periodically so that the display gives the impression of a kaleidoscope or a pinwheel.

## HOW TO USE IT

Set NTURTLES to a desired value between 0 and 36 (default value is 10). NTURTLES 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 NTURTLES, 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 NTURTLES. RESTORE kills all turtles greater than NTURTLES and tells all turtles to put their pen down. Killing all turtles greater than NTURTLES 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.

## THINGS TO NOTICE

An important thing to notice here is the number given in COUNT-TURTLES. Right away, it becomes much larger than NTURTLES, but quickly settles on some nice big number. Take a look at the Procedures Window. Initially, upon setup, there are NTURTLES 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 NTURTLES is exploding into a number much larger than NTURTLES 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 NTURTLES 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 'curr-color-sep') alters the appearance of the pattern. Turn COLOR-SHIFT on, and let 'curr-color-sep' become very large. Then watch what happens when it is small, maybe zero or some negative number.

## THINGS TO TRY

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 NTURTLES 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?

## EXTENDING THE MODEL

Whenever a turtle is hatched by one of NTURTLES, 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 NTURTLES 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'.

## NETLOGO FEATURES

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.)

## NOTES ON THE SHAPES

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.

## SLIDER DESCRIPTIONS

EXPANDER: Numbered from 0 to 90 and increments by 1. Expands and contracts the square created by LEFT-SQUARE. Associated with PATTERN-5.

DIRECTION: Numbered from 0 to 10 and increments by 0.1 or (1/10). Turns a turtle to the right by the number of degrees specified by the slider. Associated with PATTERN-3 and PATTERN-1.

## WHAT THE PATTERNS DO

about PATTERN-1: 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.

about PATTERN-2: 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 nturtles 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.

about PATTERN-3: 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.

about PATTERN-4: 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.

about PATTERN-5: Every turtle hatches another turtle that performs the LEFT-SQUARE function and then dies.

about PATTERN-6: 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.

## NOTES ON THE CODE

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.

## HOW TO CITE

If you mention this model in a publication, we ask that you include these citations for the model itself and for the NetLogo software:

- Wilensky, U. (1998). NetLogo Geometron Top-Down model. http://ccl.northwestern.edu/netlogo/models/GeometronTop-Down. Center for Connected Learning and Computer-Based Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL.
- Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL.

## COPYRIGHT AND LICENSE

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 http://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 uri@northwestern.edu.

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.

## Comments and Questions

globals [ curr-color-sep ;; spread of the colors in the kaleidoscope counter ] turtles-own [ new? ;; was the turtle just created? type-a? ;; used when turtles with different behaviors are hatched ] to setup clear-all ;; some of the patterns assume ;; evenly spaced turtles create-ordered-turtles nturtles ask turtles [pen-down set new? false ] set curr-color-sep color-sep set counter 0 end to lift-pen ask turtles [if (who >= nturtles) [die] pen-up ] clear-patches end to restore ask turtles [if (who >= nturtles) [die] pen-down ] clear-patches end to color-shift ifelse shift-direction = "increment" [set curr-color-sep (curr-color-sep + (random-float 1.0))] [set curr-color-sep (curr-color-sep - (random-float 1.0))] wait 1 end ;;PATTERN-1 ;;--------- ;;Turtles draw circles creating an overall circular design. to pattern-1 ;;turtle procedure if (new?) [set color (who / curr-color-sep) if (follow-turtle) [if (who = (50 + nturtles)) [pen-down] ] right-circle left-circle die ] if (( who mod 10 ) = 0) [rt direction fd 0.5 if (count turtles + 1 <= max-num) [hatch 1 [set new? true] ] ] end ;;PATTERN-2 ;;--------- ;;Turtles draw a combination of hexagons and octagons, Overall shape determined by NTURTLES. to pattern-2 ;;turtle procedure if (new?) [ifelse (type-a?) [set color (who / curr-color-sep) if (follow-turtle) [if (who = (60 + nturtles)) [pen-down] ] hexagon die ] [set color (who / curr-color-sep) if (follow-turtle) [if (who = (50 + nturtles)) [pen-down] ] octagon die ] ] ifelse ((who mod 2) = 0) [rt 1 fd 1 if (count turtles + 1 <= max-num) [hatch 1 [set new? true set type-a? true ] ] ] [lt 1 fd 1 if (count turtles + 1 <= max-num) [hatch 1 [set new? true set type-a? false ] ] ] end ;;PATTERN-3 ;;--------- ;;Turtles create only pentagons, slight variations in their origin create the overall effect. to pattern-3 ;;turtle procedure if (new?) [set color (who / curr-color-sep) if (follow-turtle) [if (who = (60 + nturtles)) [pen-down] ] pentagon die ] if (who mod 5) = 0 [rt direction fd 0.5 if (count turtles + 1 <= max-num) [hatch 1 [set new? true] ] ] end ;;PATTERN-4 ;;--------- ;;Turtles draw ninegons and left circles creating an overall circular pattern. to pattern-4 ;;turtle procedure if (new?) [ifelse (type-a?) [set color (who / curr-color-sep) if (follow-turtle) [if (who = (1583 + nturtles)) [pen-down] if (who = (1087 + nturtles)) [pen-down] ] nine-gon die ] [set color (who / curr-color-sep) if (follow-turtle) [if (who = (214 + nturtles)) [pen-down] ] left-circle die ] ] ifelse ((who mod 3) = 0) [rt 1 if (count turtles + 1 <= max-num) [hatch 1 [set new? true set type-a? true ] ] ] [lt 1 if (count turtles + 1 <= max-num) [hatch 1 [set new? true set type-a? false ] ] ] end ;;PATTERN-5 ;;--------- ;;Turtles draw a left square and then die. to pattern-5 ;;turtle procedure if (new?) [set color (who / curr-color-sep) if (follow-turtle) [if (who = (80 + nturtles)) [pen-down] ] left-square die ] if (count turtles + 1 <= max-num) [hatch 1 [set new? true] ] end ;;PATTERN-6 ;;--------- ;;Turtles draw several shapes, however overall design remains circular. to pattern-6 ;;turtle procedure if count turtles > max-num [if (who > max-num) [die] stop ] if (new?) [ifelse (type-a?) [set color (who / curr-color-sep) if (follow-turtle) [if (who = (60 + nturtles)) [pen-down] ] pentagon hexagon left-circle die ] [set color (who / curr-color-sep) if (follow-turtle) [if (who = (60 + nturtles)) [pen-down] ] nine-gon octagon right-circle die ] ] if (count turtles + 1 <= max-num) [hatch 1 [set new? true set type-a? true ] ] if (count turtles + 1 <= max-num) [hatch 1 [set new? true set type-a? false ] ] end ;;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. to right-circle ;;turtle procedure repeat 180 [fd 1.5 rt 2 ] end ;;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 0one turtle with the pen down. ;;A turtle will create a circle heading in the left direction. to left-circle ;;turtle procedure repeat 180 [fd 1.5 lt 2 ] end ;;LEFT-SQUARE ;;----------- ;;Performs the following procedure 4 times: ;;Move forward EXPANDER steps and turn left 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. to left-square ;;turtle procedure repeat 4 [fd expander lt 90 ] end ;;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. to right-triangle ;;turtle procedure repeat 3 [fd expander rt 120 ] end ;;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. to octagon ;;turtle procedure repeat 8 [fd 30 lt 45 ] end ;;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. to pentagon ;;turtle procedure repeat 5 [fd 35 rt 72 ] end ;;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. to hexagon ;;turtle procedure repeat 6 [fd 30 rt 60 ] end ;;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. to nine-gon ;;turtle procedure repeat 9 [fd 35 lt 40 ] end ; Copyright 1998 Uri Wilensky. ; See Info tab for full copyright and license.

There are 10 versions of this model.

## Attached files

File | Type | Description | Last updated | |
---|---|---|---|---|

Geometron Top-Down.png | preview | Preview for 'Geometron Top-Down' | almost 6 years ago, by Uri Wilensky | Download |

This model does not have any ancestors.

This model does not have any descendants.