globals [ max-percent clock ] to setup ;;create turtles with random colors ca set clock 0 crt number ask turtles [ set color ((random colors) * 10) + 5 if (color = 75) ;; 75 is too close to another color so change it to 125 [ set color 125 ] setxy (random-float screen-size-x) (random-float screen-size-y) ] setup-plots do-plots end to go ask turtles [ rt random-float 50 - random-float 50 meet fd 1 ] find-top-species set clock clock + 1 do-plots if (variance values-from turtles [color]) = 0 [ stop ] end to meet ;;turtle procedure - when two turtles are next door, ;;the left one changes to the color of the one to its right if any? turtles-at 1 0 [set color color-of one-of turtles-at 1 0] end to find-top-species ;;find the percentage of the most populous species locals [species-color species-number species-number-temp] set species-color 5 set species-number 0 repeat number [ set species-number-temp (count turtles with [color = species-color]) if species-number-temp > species-number [ set species-number species-number-temp] set species-color species-color + 10 ] set max-percent (100 * species-number / number) end ;; initializes all plots to setup-plots set-current-plot "Turtle Populations" set-plot-y-range 0 count turtles end to do-plots set-current-plot-pen "color5" plot count turtles with [color = 5] set-current-plot-pen "color15" plot count turtles with [color = 15] set-current-plot-pen "color25" plot count turtles with [color = 25] set-current-plot-pen "color35" plot count turtles with [color = 35] set-current-plot-pen "color45" plot count turtles with [color = 45] set-current-plot-pen "color55" plot count turtles with [color = 55] set-current-plot-pen "color65" plot count turtles with [color = 65] set-current-plot-pen "color125" plot count turtles with [color = 125] set-current-plot-pen "color85" plot count turtles with [color = 85] set-current-plot-pen "color95" plot count turtles with [color = 95] 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 2001 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. (2001). NetLogo GenDrift T interact model. ; http://ccl.northwestern.edu/netlogo/models/GenDriftTinteract. ; 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/GenDriftTinteract ; for terms of use. ; ; *** End of NetLogo Model Copyright Notice *** @#$#@#$#@ GRAPHICS-WINDOW 305 10 615 341 12 12 12.0 1 10 1 1 1 CC-WINDOW 5 197 288 325 Command Center BUTTON 149 47 222 80 go go T 1 T OBSERVER T BUTTON 69 47 146 80 setup setup NIL 1 T OBSERVER T SLIDER 149 90 278 123 colors colors 2 10 5 1 1 NIL SLIDER 6 90 147 123 number number 1 200 70 1 1 NIL PLOT 5 345 606 540 Turtle Populations Time Number 0.0 100.0 0.0 70.0 true false PENS "color5" 1.0 0 -7566196 true "color15" 1.0 0 -65536 true "color25" 1.0 0 -44544 true "color35" 1.0 0 -6524078 true "color45" 1.0 0 -256 true "color55" 1.0 0 -11352576 true "color65" 1.0 0 -16711936 true "color125" 1.0 0 -65281 true "color85" 1.0 0 -16711681 true "color95" 1.0 0 -16745473 true MONITOR 55 134 174 183 most populous (%) max-percent 3 1 MONITOR 185 134 235 183 clock clock 0 1 @#$#@#$#@ WHAT IS IT? ----------- This model is an example of random selection. It shows that turtles that randomly exchange colors converge on a single color. The model starts with a random distribution of colored agents. Turtles move by wiggling randomly across the screen. When two turtles are next to each other, one turtle changes its color to the color of the other one. Gradually a color will gain a slight dominance. By statistical advantage, a dominant color becomes more likely to have more colors like it. However, because the process is random, there will usually be a series of dominant colors before one color finally wins. Equally important is the fact that a color can never come back once it dies out. The idea, explained in more detail in Dennett's "Darwin's Dangerous Idea", is that trait drifts can occur without any particular purpose or 'selecting pressure'. HOW TO USE IT: -------------- The SETUP button intializes the model. The GO button runs the model. The NUMBER slider sets the number of turtles. The COLORS slider selects the number of competing colors, up to ten. THINGS TO NOTICE: ---------------- There are two monitors, one showing the percentage of turtles which have the most common color, and the other showing the number of turns. Notice that often colors that start with a higher initial number fail to dominate in the end. EXTENDING THE MODEL: -------------------- In this model, a turtle looks one patch to its right. If there's another turtle there, the "looking" turtle changes to that turtle's color. Since the turtles move randomly about the screen, it's a matter of chance which turtle will change to the color of its neighbor. Think of other rules for turtle interactions, random or otherwise, by which a turtle color might "take over". RELATED MODELS: --------------- GenDrift (P Global) GenDrift (P local) GenDrift (T reproduce) CREDITS AND REFERENCES: ----------------------- To refer to this model in academic publications, please use: Wilensky, U. (2001). NetLogo GenDrift T interact model. http://ccl.northwestern.edu/netlogo/models/GenDriftTinteract. 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/GenDriftTinteract for terms of use. @#$#@#$#@ default true 0 Polygon -7566196 true true 150 5 40 250 150 205 260 250 circle true 0 Circle -7566196 true true 24 23 256 @#$#@#$#@ NetLogo 2.0beta5 @#$#@#$#@ @#$#@#$#@ @#$#@#$#@