globals [ iterations ] turtles-own [ new? ] ; setup the initial turtle and its properties to setup ca crt 1 set iterations 0 ask turtles [ set shape "line" set color init-color setxy init-x init-y set heading 0 pd ] end ; have all non-new turtles draw an iteration of the tree to iterate ask turtles [ set new? false pd ] ; here are the commands to draw the tree ask turtles with [ not new? ] [ fd 4 rt 15 fd 8 hatch 1 [ set new? true ] set color (color + color-inc) rt 180 jump 8 rt 180 lt 15 fd 4 lt 15 hatch 1 [ set new? true ] set color (color + color-inc) fd 8 die ] set iterations iterations + 1 end ; *** NetLogo Model Copyright Notice *** ; ; This model was created as part of the project: ; PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN ; CLASSROOMS. The project gratefully acknowledges the support of the ; National Science Foundation (REPP program) -- grant number REC #9814682. ; ; Copyright 2001 by Uri Wilensky. Updated 2001. All rights reserved. ; ; Permission to use, modify or redistribute this model is hereby granted, ; provided that both of the following requirements are followed: ; a) this copyright notice is included. ; b) this model will not be redistributed for profit without permission ; from Uri Wilensky. ; Contact Uri Wilensky for appropriate licenses for redistribution for ; profit. ; ; To refer to this model in academic publications, please use: ; Wilensky, U. (2001). NetLogo Tree Simple model. ; http://ccl.northwestern.edu/netlogo/models/TreeSimple. ; Center for Connected Learning and Computer-Based Modeling, ; Northwestern University, Evanston, IL. ; ; In other publications, please use: ; Copyright 1998 by Uri Wilensky. All rights reserved. See ; http://ccl.northwestern.edu/netlogo/models/TreeSimple ; for terms of use. ; ; *** End of NetLogo Model Copyright Notice *** @#$#@#$#@ GRAPHICS-WINDOW 265 10 677 443 100 100 2.0 1 10 1 1 1 CC-WINDOW 8 283 252 448 Command Center BUTTON 94 42 157 75 Go Once iterate NIL 1 T OBSERVER T BUTTON 22 42 77 75 Setup setup NIL 1 T OBSERVER T SLIDER 8 79 252 112 color-inc color-inc 0.0 100.0 7.0 1.0 1 NIL SLIDER 8 118 252 151 init-color init-color 0.0 140.0 45.0 1.0 1 NIL SLIDER 8 154 252 187 init-x init-x -125.0 125.0 0.0 1.0 1 NIL SLIDER 8 191 252 224 init-y init-y -100.0 100.0 -50.0 1.0 1 NIL BUTTON 176 42 231 75 Go iterate T 1 T OBSERVER T MONITOR 8 229 96 278 Num Turtles count turtles 10 1 MONITOR 173 229 252 278 Iterations iterations 3 1 @#$#@#$#@ WHAT IS IT? ----------- 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. HOW TO USE IT ------------- Perhaps the best way to start with this program is by looking at an example of a fractal. In the "Interface" tab, press the SETUP button to set up a fractal that draws a tree. Then press the GO button and watch it draw. You can also have the fractal drawn one step a time. Once you click the SETUP button, instead of clicking the GO button, click on the GO ONCE button. This draws the fractal by drawing one iteration of the fractal per click as opposed to continuously, like the GO button. If you don't like the location of the fractal on the graphics window you can change it by modifying the value of the following sliders: The INIT-X slider sets the initial x coordinate of the first turtle. It changes the horizontal starting location of the original turtle. The INIT-Y slider 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: The INIT-COLOR slider sets the initial color of the first turtle. The value of the COLOR-INC slider is added to the turtles color anytime a new turtle hatches. The NUM TURTLES monitor indicates how many turtles are in the graphics window currently. The ITERATIONS monitor shows how many times through the iterate procedure the model has gone. Be aware that due to the varying systems that NetLogo runs on, it might be best to limit the number of iterations to about 8 or 9 of any particular fractal. If you go much more than that, you might have trouble with memory problems. THINGS TO NOTICE ---------------- Notice the self-similarity of the fractal 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. THINGS TO TRY ------------- Now that you have played around with settings for the example provided, why not try making your own tree fractals. Use NetLogo commands to make your own fractals that look like trees. Then change the initial color and color increment values to make the fractal more interesting to look at. EXTENDING THE MODEL ------------------- Try adding switches or sliders such as max-increment-random-length or min-increment-random-degree or random-length that could impose a random factor to the movement of the turtles. The use of these plus the NetLogo primitive random would increase the realism in a fractal. This would be especially useful in drawing realistic trees since branches are not spaced uniformly on a tree nor do they all branch from the trunk at the same angle. Pick up a book on fractals or search on the internet to find fractals that are interesting and try to create them. Also try to find different types of fractals such as L-System Fractals. You may find some resources below. 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? Try to make a realistic forest. Does this require vastly different commands from making a realistic tree? NETLOGO FEATURES ---------------- Notice the use of agentsets to make some of the commands only affect certain turtles. For example, the reporter WITH is used to isolate non-new turtles and have the rules only affect them. Also notice how the fractals are formed using several agents following the same rules through the use of the "hatch" primitive which makes it so simple to generate fractals like a tree. RELATED MODELS -------------- L-System Fractals CREDITS AND REFERENCES ---------------------- This site offers an introduction to fractals, including L-system fractals as well as others. http://www.cs.wpi.edu/~matt/courses/cs563/talks/cbyrd/pres1.html The Fractal Geometry of Nature by Benoit Mandelbrot To refer to this model in academic publications, please use: Wilensky, U. (2001). NetLogo Tree Simple model. http://ccl.northwestern.edu/netlogo/models/TreeSimple. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL. In other publications, please use: Copyright 2001 by Uri Wilensky. All rights reserved. See http://ccl.northwestern.edu/netlogo/models/TreeSimple for terms of use. @#$#@#$#@ default true 0 Polygon -7566196 true true 150 5 40 250 150 205 260 250 arrow true 0 Polygon -7566196 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150 box true 0 Polygon -7566196 true true 45 255 255 255 255 45 45 45 circle true 0 Circle -7566196 true true 35 35 230 line true 0 Line -7566196 true 150 0 150 295 person false 0 Circle -7566196 true true 155 20 63 Rectangle -7566196 true true 158 79 217 164 Polygon -7566196 true true 158 81 110 129 131 143 158 109 165 110 Polygon -7566196 true true 216 83 267 123 248 143 215 107 Polygon -7566196 true true 167 163 145 234 183 234 183 163 Polygon -7566196 true true 195 163 195 233 227 233 206 159 spacecraft true 0 Polygon -7566196 true true 150 0 180 135 255 255 225 240 150 180 75 240 45 255 120 135 thin-arrow true 0 Polygon -7566196 true true 150 0 0 150 120 150 120 293 180 293 180 150 300 150 truck-down false 0 Polygon -7566196 true true 225 30 225 270 120 270 105 210 60 180 45 30 105 60 105 30 Polygon -8716033 true false 195 75 195 120 240 120 240 75 Polygon -8716033 true false 195 225 195 180 240 180 240 225 truck-left false 0 Polygon -7566196 true true 120 135 225 135 225 210 75 210 75 165 105 165 Polygon -8716033 true false 90 210 105 225 120 210 Polygon -8716033 true false 180 210 195 225 210 210 truck-right false 0 Polygon -7566196 true true 180 135 75 135 75 210 225 210 225 165 195 165 Polygon -8716033 true false 210 210 195 225 180 210 Polygon -8716033 true false 120 210 105 225 90 210 turtle true 0 Polygon -7566196 true true 138 75 162 75 165 105 225 105 225 142 195 135 195 187 225 195 225 225 195 217 195 202 105 202 105 217 75 225 75 195 105 187 105 135 75 142 75 105 135 105 @#$#@#$#@ NetLogo 2.0beta4 @#$#@#$#@ setup repeat 10 [ iterate ] @#$#@#$#@ @#$#@#$#@