patches-own [ heat ] to setup ca create-custom-turtles num-turtles ; each turtle is like a heat source [ setxy (random-float screen-size-x) (random-float screen-size-y) ; position the turtles randomly hide-turtle ; so we don't see the turtles themselves, just the heat they produce set heat turtle-heat ] ; turtles set the patch variable recolor-patches ; color patches according to heat end to go ask turtles [ set heat turtle-heat ] ; turtles set the patch variable if wander? [ ask turtles [ wander ] ] ; movement of turtles is controlled by WANDER? switch diffuse heat diffusion-rate ; this causes the "spreading" of heat recolor-patches ; color patches according to heat end to wander ; turtle procedure rt random 50 - random 50 fd turtle-speed end to recolor-patches ; color patches according to heat ifelse roy-g-biv? [ recolor-roy-g-biv ] [ recolor-normal ] end to recolor-normal ask patches [ set pcolor heat ] end to recolor-roy-g-biv ; the longer the model runs, the hotter all the patches get (since no ; heat is ever lost), so assigning fixed temperatures to the color ; won't produce nice-looking results; therefore we scale the color ; spectrum to fit whatever the current range of temperatures is ; among all the patches locals [ heat-list min-heat max-heat] set heat-list values-from patches [ heat ] set min-heat min heat-list set max-heat max heat-list ; the 1.5 and 4.0 in the formulas below were arrived at by trial and ; error on what looked best ask patches [ set pcolor hsb ((1.5 * (heat - min-heat)) / (max-heat - min-heat)) ; hue 1.0 ; saturation ((4.0 * (heat - min-heat)) / (max-heat - min-heat)) ; brightness ] end ; *** NetLogo Model Copyright Notice *** ; ; 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. ; ; Copyright 1997 by Uri Wilensky. 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. ; ; This model was converted to NetLogo 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. ; Converted from StarLogoT to NetLogo, 2001. Updated 2002. ; ; To refer to this model in academic publications, please use: ; Wilensky, U. (1997). NetLogo Diffusion Graphics model. ; http://ccl.northwestern.edu/netlogo/models/DiffusionGraphics. ; 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/DiffusionGraphics ; for terms of use. ; ; *** End of NetLogo Model Copyright Notice *** @#$#@#$#@ GRAPHICS-WINDOW 253 18 568 354 30 30 5.0 0 10 1 1 1 CC-WINDOW 255 362 556 485 Command Center SLIDER 7 154 242 187 diffusion-rate diffusion-rate 0.0 1.0 1.0 0.1 1 NIL SLIDER 7 109 242 142 num-turtles num-turtles 1 20 10 1 1 NIL BUTTON 44 50 114 84 setup setup NIL 1 T OBSERVER SWITCH 69 365 189 398 roy-g-biv? roy-g-biv? 1 1 -1000 SWITCH 69 321 188 354 wander? wander? 0 1 -1000 BUTTON 126 50 195 84 go go T 1 T OBSERVER SLIDER 7 199 242 232 turtle-heat turtle-heat -139.0 500.0 139.0 1.0 1 NIL SLIDER 7 244 242 277 turtle-speed turtle-speed 0.0 10.0 1.0 0.1 1 NIL @#$#@#$#@ WHAT IS IT? ----------- Diffusion Graphics is unlike most other NetLogo models, in that it really doesn't 'model' anything. It simply explores the power behind an interesting patch primitive: 'diffuse'. In this model, the turtles are "hot spots" -- they set a certain value (a patch variable called 'heat') to the maximum level every time step. Each patch (through the 'diffuse' primitive) then shares its value of 'heat' with its surrounding patches. It's not intended to closely model real heat, it's just a number that behaves something like heat -- it slowly spreads itself evenly across a plane. (See the 'Diffusion' model for a model that models real heat more closely.) Here you can watch what happens as hot-spots interact with each other, as they move around, as their values become negative, or as the 'heat' slowly decays down to nothing. The whole point of the project is to give you an idea how patches interact via the 'diffuse' primitive. (Or maybe just to give you something nice to stare at if you're bored.) HOW TO USE IT ------------- Two buttons, SETUP and GO, control execution of the model. As in most NetLogo models, the SETUP button will initialize the 'hot-spots' and other variables, preparing the model to be run. The GO button, a forever button, will then run the model. Four sliders and two switches determine the various properties of the model. Each of them can be set prior to initialization; most can be used mid-run to affect what will happen. NUM-TURTLES determines how many turtles there are. TURTLE-SPEED determines how fast they move. Each turtle sets the 'heat' of the patch it is over to TURTLE-HEAT. Then that patch diffuses it into the nearby patches. The DIFFUSION-RATE slider is the rate at which the colors diffuse out from each patch. All patches diffuse their color value to their neighbors each time step. DIFFUSION-RATE is simply the fraction of this color leaked out. The WANDER? switch, if on, allows the turtles to move around the graphics screen. If the switch is off, the turtles will stay rooted in place. Finally, the ROY-G-BIV? switch allows you to switch from the NetLogo 0-to-140 color representation (which might not make too much sense unless you are already used to it), to a more standard representation. The name "ROY-G-BIV?" comes from the common mnemonic for remembering the colors of the rainbow: red, orange, yellow, green, blue, indigo, violet. THINGS TO NOTICE ---------------- Mainly what Diffusion Graphics will show you is how patch-color is diffused in NetLogo. The graphical display may evoke fractal imagery, or a topographical landscape. Diffusion Graphics really does bring about a topography of sorts, with the turtles being peaks, and the darkest colors being valleys. The model essentially tries to then smooth out these differences. Let the model run for a while with WANDER all off (all set to 0). Watch what happens to the 'terrain'. What do you predict will eventually happen? Compare and contrast between the two color representations that 'diffusion-graphics' has to offer: with ROY-G-BIV? on or off. Which mode do you prefer? Do you understand NetLogo's 0-140 color model well enough to understand why that mode produces the kinds of patterns it does? This model was built to please. Just play around with the sliders and switches. Later, try altering the code and see what works (and what doesn't work, too). THINGS TO TRY ------------- Try setting TURTLE-HEAT to a very large number. What happens? What does this show you about NetLogo's color model? Try setting TURTLE-HEAT to a negative number. What happens? What does this show you about NetLogo's color model? Try setting the patch size to a small number for a richer display. Or make the patch size large, for a 'zoomed-in' perspective. EXTENDING THE MODEL ------------------- Change it so that the NUM-TURTLES slider will the change the number of turtles on the fly, instead of requiring you to hit SETUP. In 'diffusion-graphics', the position of each turtle is determined randomly at setup. Change the model so that the user may position turtles with the mouse. NETLOGO FEATURES ---------------- The Diffusion Graphics model was designed around the 'diffuse' primitive. 'diffuse' is an observer primitive that takes two inputs, a patch variable and a number. 'diffuse' makes all the patches share that patch variable with their eight neighbors. The second input is a number between 0 and 1.0 determines what fraction of the patch variable is shared. (In this model, the amount shared is controlled by the CHANGE-RATE slider.) So for example, if I ask the observer to 'diffuse heat 0.5', the observer tells each patch to give half of 'heat' to the eight other patches. If a patch had 80 to begin with, then it keeps 40 and gives 5 away to each neighbor. The total value of 'heat' for all the patches remains constant. There is also a 'diffuse4' primitive where the patches only share with their neighbors in the north, south, east, and west directions, not with their diagonal neighbors. CREDITS AND REFERENCES ---------------------- To refer to this model in academic publications, please use: Wilensky, U. (1997). NetLogo Diffusion Graphics model. http://ccl.northwestern.edu/netlogo/models/DiffusionGraphics. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL. In other publications, please use: Copyright 1997 by Uri Wilensky. All rights reserved. See http://ccl.northwestern.edu/netlogo/models/DiffusionGraphics for terms of use. @#$#@#$#@ default true 0 Polygon -7566196 true true 150 5 40 250 150 205 260 250 @#$#@#$#@ NetLogo 2.0alpha1 @#$#@#$#@ @#$#@#$#@ @#$#@#$#@