;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Habitat fragmentation model written by George Kampis and Istvan Karsai, 2007-2010 ; Realizes a general spatial predator prey system (using wolf and sheep rhetoric) ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Preparation stuff ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; globals [ ticksvalue grass plot-ticks x-min x-max y-min y-max volume sheep-time wolf-time sheep-born sheep-new sheep-rate wolf-born wolf-new wolf-rate total-born dead-sheep dead-wolf sheep-now wolf-now grass-regrowth-time-effective] breed [ sheep a-sheep ] breed [ wolves wolf ] turtles-own [ energy ] patches-own [ countdown ] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Init and Setup ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to init ca end to setup ca let seed random 10000 random-seed seed set ticksvalue 0 set plot-ticks 0 set x-max 0 set y-max 0 set x-min 100000 set y-min 100000 ask patches [ set pcolor green ] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; let there be grass, grass is just green color ask patches [ set countdown random grass-regrowth-time ;; initialize grass grow clocks randomly ; if (random 2) = 0 ;;half the patches start out with grass ; [ set pcolor brown ] ] set-default-shape sheep "sheep" create-sheep initial-number-sheep ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; create the sheep, then initialize their variables [ set color white set size 1.5 ;; easier to see set label-color blue - 2 set energy random (2 * sheep-gain-from-food) setxy random-xcor random-ycor ] set-default-shape wolves "wolf" create-wolves initial-number-wolves ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; create the wolves, then initialize their variables [ set color black set size 1.5 ;; easier to see set energy random (2 * wolf-gain-from-food) setxy random-xcor random-ycor ] if movie? [movie-start "out.mov" movie-set-frame-rate 30 ] if file? [ file-open user-new-file file-print "Habitat Fragmentation Model (c) 2007-2010 George Kampis and Istvan Karsai" file-print "" file-print "control parameter: wolf-gain-from food" file-type "random seed is: " file-print seed file-print "time wolf-gain-from-food grass sheep wolves sheep-rate wolf-rate sheep-time wolf-time phase-tick phase-volume sheep-born wolf-born total-born" ] do-plot end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Go (one time step, NetLogo iterates it by itself) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to go if (not any? turtles or ticks = timeup) [if file? [ file-close ] if movie? [ movie-close ] stop ] ;; if time's up or all are dead, stop ; ;; a little clean-up: kill objects climbed into the wall ask turtles with [ pcolor = 45 or pcolor = 45.5] [die] set sheep-now count sheep set wolf-now count wolves set sheep-new 0 set wolf-new 0 set dead-sheep 0 set dead-wolf 0 set ticksvalue ticksvalue + 1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; sheep stuff begins here ask sheep [ move-sheep set energy energy - 1 ;; deduce energy for sheep eat-grass reproduce-sheep death-sheep ] set sheep-born sheep-born + sheep-new ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; wolf stuff begins here ask wolves [ move-wolf set energy energy - 1 ;; wolves lose energy too catch-sheep reproduce-wolves death-wolf ] if (count sheep > 0) [ set sheep-time sheep-time + 1 ] if (count wolves > 0) [set wolf-time wolf-time + 1 ] set wolf-born wolf-born + wolf-new set total-born sheep-born + wolf-born ifelse (count sheep = 0) [set sheep-rate 0] [set sheep-rate sheep-new / count sheep] ifelse (count wolves = 0) [set wolf-rate 0] [set wolf-rate wolf-new / count wolves] ask patches [ grow-grass ] do-plot ;; plot all populations, do movies, etc. end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Individual operation blocks: move, eat, reproduce, die ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to move-sheep ;; turtle procedure for sheep rt random-float 50 - random-float 50 ;; turn a bit randomly bounce fd sheep-speed ;; forward by what the speed parameter says end to move-wolf ;; turtle procedure for all wolves rt random-float 50 - random-float 50 ;; turn a bit randomly bounce fd wolf-speed ;; forward by what the speed parameter says end to eat-grass ;; sheep procedure ;; sheep eat grass, turn the patch brown if pcolor = green [ set pcolor brown set energy energy + sheep-gain-from-food ;; sheep gain this much energy by eating ] end to reproduce-sheep ;; sheep procedure if random-float 100 < sheep-reproduce [ ;; throw "dice" to see if you will reproduce set energy (energy / 2) ;; divide energy between parent and offspring set sheep-new sheep-new + 1 hatch 1 [ rt random-float 360 ] ;; hatch an offspring ] end to reproduce-wolves ;; wolf procedure if random-float 100 < wolf-reproduce [ ;; throw "dice" to see if you will reproduce set energy (energy / 2 ) ;; divide energy between parent and offspring set wolf-new wolf-new + 1 hatch 1 [ rt random-float 360 ] ;; hatch an offspring ] end to catch-sheep ;; wolf procedure let prey one-of (sheep-here) ;; grab a random sheep if prey != nobody ;; did we get one? if so, [ ask prey [ die ] ;; kill it set energy energy + wolf-gain-from-food ] ;; get energy from eating end to death-sheep ;; turtle procedure ;; when energy dips below zero, die if energy < 0 [ set dead-sheep dead-sheep + 1 die ] end to death-wolf ;; turtle procedure ;; when energy dips below zero, die if energy < 0 [ set dead-wolf dead-wolf + 1 die ] end to grow-grass ;; patch procedure ; ;; countdown on brown patches, if reach 0, grow some grass set grass-regrowth-time-effective grass-regrowth-time if grass-init-slow? [if (ticks < 50) [set grass-regrowth-time-effective 30]] ;; A HACK FOR STARTNG THE TESTS if pcolor = brown [ ifelse countdown <= 0 [ set pcolor green set countdown grass-regrowth-time-effective ] [ set countdown (countdown - 1) ] ] end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Plotting module starts here ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to do-plot let plmax every-n-steps if (plot-ticks >= plmax) [ set volume (x-max - x-min) * (y-max - y-min) / 10000 set-current-plot "phase-volume" plot volume ] ; set-current-plot "populations" ifelse clear-populations-plot [clear-plot] [] ; plot population numbers as numbers set-current-plot-pen "sheep" plot count sheep set-current-plot-pen "wolves" plot count wolves set-current-plot-pen "grass / 4" set grass count patches with [ pcolor = green ] / 4 ;; divide by four to keep it within similar plot grass ;; range as wolf and sheep populations ; set-current-plot "phase-plot-total-time" let x count sheep let y count wolves plotxy x y ; set-current-plot "phase-plot" ifelse clear-phase-plot [if (plot-ticks >= plmax) [ clear-plot set plot-ticks 0 set x-max 0 set y-max 0 set x-min 100000 set y-min 100000]] [] plotxy x y if (x-max < x) [set x-max x] if (y-max < y) [set y-max y] if (x-min > x) [set x-min x] if (y-min > y) [set y-min y] ; set-current-plot "death-rates" set-current-plot-pen "sheep-rate" ifelse (sheep-now = 0) [ ] [ plot ( dead-sheep / sheep-now ) * 100 ] ;; now plot death rate set-current-plot-pen "wolf-rate" ifelse (wolf-now = 0) [ ] [ plot ( dead-wolf / wolf-now ) * 100 ] ;; plot death rate as above ; set-current-plot "reproduction-rates" set-current-plot-pen "sheep-rate" plot sheep-rate * 100 ;; that's repro rate in % set-current-plot-pen "wolf-rate" plot wolf-rate * 100 ;; thats rep rate in % ; if movie? [movie-grab-view] ;; make movie of the field if switch is on ;if movie? [movie-grab-interface] ;; an alternative possibility: of whole interface if file? [ file-write ticks file-write wolf-gain-from-food file-write grass file-write count sheep file-write count wolves file-write sheep-rate file-write wolf-rate file-write sheep-time file-write wolf-time file-write plot-ticks file-write volume file-write sheep-born file-write wolf-born file-write total-born file-print " " ] set plot-ticks plot-ticks + 1 end ;====================================================================================================== ; Boxes, grids, doors - that is, space fragmentation etc. module begins here ;====================================================================================================== to draw-box ;; this draws the thick walls of the universe ; ;; turtles like to crawl through if not thick enough ; draw left and right walls ask patches with [abs pxcor = max-pxcor] [ set pcolor 45 ] ;; 45 is just a fancy name for yellow ask patches with [abs pxcor = max-pxcor - 1] [ set pcolor 45] ask patches with [abs pxcor = max-pxcor - 2] [ set pcolor 45] ; draw top and bottom walls ask patches with [abs pycor = max-pycor] [ set pcolor 45.5 ] ;; looks yellow too ;-) ask patches with [abs pycor = max-pycor - 1] [ set pcolor 45.5 ] ;; looks yellow too ;-) ask patches with [abs pycor = max-pycor - 2] [ set pcolor 45.5 ] ;; looks yellow too ;-) end to draw-grid ;; draws the grid of yellow separating walls to form boxes draw-xgrid draw-ygrid end to undraw-grid ;; if we want to undo the yellow walls undraw-xgrid undraw-ygrid end to draw-xgrid let nx num-walls if (nx = 0) [stop] ;; dont divide by zero let dist-x int ( max-pxcor / nx) let step 0 repeat nx [ ask patches [ if ( abs (pxcor) = (dist-x * step) or abs (pxcor) = (dist-x * step + 1)) [set pcolor 45] ;; 45 is just yellow ] set step (step + 1) ] end to undraw-xgrid let nx num-walls if (nx = 0) [stop] ;; dont divide by zero let dist-x int ( max-pxcor / nx) let step 0 repeat nx [ ask patches [ if ( abs (pxcor) = (dist-x * step) or abs (pxcor) = (dist-x * step + 1)) [set pcolor green] ;; undoing means painting green ] set step (step + 1) ] end to draw-ygrid let ny num-walls if (ny = 0) [stop] ;; dont divide by zero let dist-y int (max-pycor / ny) let step 0 repeat ny [ ask patches [ if ( abs (pycor) = (dist-y * step) or abs (pycor) = (dist-y * step + 1)) [set pcolor 45.5] ;; 45.5 is yellow too.... ] set step (step + 1) ] end to undraw-ygrid let ny num-walls if (ny = 0) [stop] ;; dont divide by zero let dist-y int (max-pycor / ny) let step 0 repeat ny [ ask patches [ if ( abs (pycor) = (dist-y * step) or abs (pycor) = (dist-y * step + 1)) [set pcolor green] ;; again, undoing is painting green ] set step (step + 1) ] end to draw-doors draw-xdoors draw-ydoors end to draw-xdoors let nx num-doors if (nx = 0) [stop] ;; dont divide by zero let dist-x int ( max-pxcor / nx) let step 0 repeat nx [ ask patches [ if ( abs (pxcor) = int ( dist-x * step + dist-x / 2 ) or abs (pxcor) = int ( dist-x * step + dist-x / 2 + 1 ) or abs (pxcor) = int ( dist-x * step + dist-x / 2 + 2 ) ) [if (not (pcolor = black)) [set pcolor green]] ;; doors are made of grass and grass is just green ] set step (step + 1) ] end to draw-ydoors let ny num-doors if (ny = 0) [stop] ;; dont divide by zero let dist-y int ( max-pycor / ny) let step 0 repeat ny [ ask patches [ if ( abs (pycor) = int ( dist-y * step + dist-y / 2 ) or abs (pycor) = int ( dist-y * step + dist-y / 2 + 1 ) or abs (pycor) = int ( dist-y * step + dist-y / 2 + 2 ) ) [if (not (pcolor = black)) [set pcolor green]] ;; doors are made of grass and grass is just green ] set step (step + 1) ] end to random-doors draw-random-xdoors draw-random-ydoors end to draw-random-xdoors let nx num-doors if (nx = 0) [stop] ;; nothing yields nothing let step 0 repeat nx [ let randx random max-pxcor ask patches [ if ( abs (pxcor) = randx or abs (pxcor) = randx + 1 or abs (pxcor) = randx + 2 ) [if (not (pcolor = black)) [set pcolor green]] ;; doors are made of grass and grass is just green ] set step (step + 1) ] end to draw-random-ydoors let ny num-doors if (ny = 0) [stop] ;; nothing yields nothing let step 0 repeat ny [ let randy random max-pycor ask patches [ if ( abs (pycor) = randy or abs (pycor) = randy + 1 or abs (pycor) = randy + 2 ) [if (not (pcolor = black)) [set pcolor green]] ;; doors are made of grass and grass is just green ] set step (step + 1) ] end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Bouncing! ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to bounce ;; turtle procedure ;; first see if there is any wall next to us let new-patch patch-ahead 1 ;; if we're not about to hit a wall, ;; then we don't need to do any further checks if (not shade-of? ([pcolor] of new-patch) yellow) ;; anything close to yellow is a wall [ stop ] ifelse ([pcolor] of new-patch = 45) ;; exact yellow is vertical, others horizontal walls [ set heading ( - heading)] [ set heading (180 - heading) ] end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; (c) George Kampis and Istvan Karsai, 2007-2010 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @#$#@#$#@ GRAPHICS-WINDOW 424 11 836 444 100 100 2.0 1 14 1 1 1 0 1 1 1 -100 100 -100 100 0 0 1 ticks SLIDER 14 346 188 379 initial-number-sheep initial-number-sheep 0 1000 1000 1 1 NIL HORIZONTAL SLIDER 14 383 188 416 sheep-gain-from-food sheep-gain-from-food 0.0 50.0 4 1.0 1 NIL HORIZONTAL SLIDER 14 418 188 451 sheep-reproduce sheep-reproduce 1.0 20.0 15 1.0 1 % HORIZONTAL SLIDER 192 346 357 379 initial-number-wolves initial-number-wolves 0 250 100 1 1 NIL HORIZONTAL SLIDER 192 382 357 415 wolf-gain-from-food wolf-gain-from-food 0.0 100.0 30 1.0 1 NIL HORIZONTAL SLIDER 192 418 357 451 wolf-reproduce wolf-reproduce 0.0 20.0 15 1.0 1 % HORIZONTAL SLIDER 10 283 141 316 grass-regrowth-time grass-regrowth-time 0 40 5 1 1 NIL HORIZONTAL BUTTON 319 11 407 44 NIL setup NIL 1 T OBSERVER NIL NIL NIL NIL BUTTON 321 241 406 275 go go T 1 T OBSERVER NIL NIL NIL NIL PLOT 13 455 485 575 populations time pop. 0.0 100.0 0.0 100.0 true true PENS "sheep" 1.0 0 -13345367 true "wolves" 1.0 0 -2674135 true "grass / 4" 1.0 0 -10899396 true MONITOR 15 576 86 621 sheep count sheep 3 1 11 MONITOR 90 576 172 621 wolves count wolves 3 1 11 MONITOR 176 576 252 621 grass / 4 count patches with [ pcolor = green ] / 4 0 1 11 TEXTBOX 19 326 159 345 Sheep settings 11 0.0 0 TEXTBOX 197 326 310 344 Wolf settings 11 0.0 0 MONITOR 487 455 565 500 time-ticks ticks 0 1 11 BUTTON 57 10 120 43 NIL init NIL 1 T OBSERVER NIL NIL NIL NIL BUTTON 325 155 408 189 draw box draw-box NIL 1 T OBSERVER NIL NIL NIL NIL BUTTON 20 61 109 94 draw walls draw-grid NIL 1 T OBSERVER NIL NIL NIL NIL SLIDER 110 61 282 94 num-walls num-walls 0 5 2 1 1 NIL HORIZONTAL TEXTBOX 8 222 391 240 ---------------------------------------------------------------------------------------------- 11 0.0 0 BUTTON 20 93 109 126 undraw walls undraw-grid NIL 1 T OBSERVER NIL NIL NIL NIL PLOT 654 455 885 575 phase-plot sheep volves 0.0 1000.0 0.0 1000.0 true true PENS "phase" 1.0 0 -16777216 true SLIDER 498 661 651 694 every-n-steps every-n-steps 0 500 130 1 1 NIL HORIZONTAL SWITCH 499 627 651 660 clear-phase-plot clear-phase-plot 1 1 -1000 SLIDER 155 284 266 317 sheep-speed sheep-speed 0 1.5 0.9 0.1 1 NIL HORIZONTAL PLOT 655 576 884 696 phase-volume NIL NIL 0.0 10.0 0.0 100.0 true false PENS "phase-volume" 1.0 0 -16777216 true PLOT 254 576 484 696 phase-plot-total-time sheep wolves 0.0 1000.0 0.0 1000.0 true false PENS "default" 1.0 0 -16777216 true TEXTBOX 53 127 324 145 ---------------------------------------------------------- 11 0.0 0 SWITCH 486 507 641 540 clear-populations-plot clear-populations-plot 1 1 -1000 MONITOR 569 576 650 621 plot-ticks plot-ticks - 1 0 1 11 MONITOR 15 626 86 671 NIL sheep-time 0 1 11 MONITOR 90 626 172 671 NIL wolf-time 0 1 11 BUTTON 320 61 408 94 draw doors draw-doors NIL 1 T OBSERVER NIL NIL NIL NIL MONITOR 14 677 86 722 NIL sheep-born 0 1 11 MONITOR 90 677 172 722 NIL wolf-born 0 1 11 MONITOR 177 677 246 722 NIL total-born 0 1 11 PLOT 842 262 1239 382 death-rates time rates % 0.0 100.0 0.0 10.0 true true PENS "wolf-rate" 1.0 0 -2674135 true "sheep-rate" 1.0 0 -13345367 true BUTTON 321 95 408 128 NIL random-doors NIL 1 T OBSERVER NIL NIL NIL NIL SLIDER 155 241 318 274 timeup timeup 0 10000 10000 1 1 NIL HORIZONTAL SWITCH 129 11 219 44 movie? movie? 1 1 -1000 SWITCH 221 11 311 44 file? file? 1 1 -1000 SLIDER 269 284 380 317 wolf-speed wolf-speed 0 1.5 0.9 0.1 1 NIL HORIZONTAL SLIDER 148 95 320 128 num-doors num-doors 0 10 2 1 1 NIL HORIZONTAL PLOT 842 138 1237 258 reproduction-rates time rates % 0.0 10.0 0.0 10.0 true true PENS "wolf-rate" 1.0 0 -2674135 true "sheep-rate" 1.0 0 -13345367 true TEXTBOX 361 387 416 429 <- adjust here ! 11 0.0 0 SWITCH 10 241 151 274 grass-init-slow? grass-init-slow? 0 1 -1000 @#$#@#$#@ WHAT IS IT? ----------- This model explores the stability of predator-prey ecosystems with fragmented habitats. HOW TO USE IT ------------- The general rule: proceed left to right, top to bottom. Never go backwards or things might crash. 1 - init (clear all), set movie and file switch (to produce "out.mov" and "out.txt", respectively) 2 - setup (defines grass and random predators and prey) 3 - draw walls for habitat fragmentation (optional) 4 - draw doors on the walls to connect fragments, or make openings w/ the mouse (optional) 5 - draw a box around the field (suggested - otherwise it's a torus!) 6 - go.. Parameters: INITIAL-NUMBER-SHEEP: The initial size of sheep population INITIAL-NUMBER-WOLVES: The initial size of wolf population SHEEP-GAIN-FROM-FOOD: The amount of energy sheep get for every grass patch eaten WOLF-GAIN-FROM-FOOD: The amount of energy wolves get for every sheep eaten SHEEP-REPRODUCE: The probability of a sheep reproducing at each time step WOLF-REPRODUCE: The probability of a wolf reproducing at each time step GRASS-REGROWTH-TIME: How long it takes for grass to regrow once it is eaten Notes: - one unit of energy is deducted for every step a wolf takes - when grass is included, one unit of energy is deducted for every step a sheep takes THINGS TO NOTICE ---------------- With increasing predator quality ("wolf gain") spatial waves can form. High densitiy waves typically lead to extinction of prey and then predator. Howwever, introducing barriers and connectors improves coexistence. THINGS TO TRY ------------- Try different framgentation schemes with different number of boxes and doors. EXTENDING THE MODEL ------------------- There are many possibilities, the most obvious being the introduction of different migration speed (and different life cycle) for predator and prey. CREDITS AND REFERENCES ---------------------- George Kampis and Istvan Karsai 2010: Breaking Waves in Population Flows, in: Kampis, G, Szathmary, E., Karsai, I, Jordan, F. (eds): Darwin Meets von Neumann. Proceedings of the 10th European Conference on Artificial Life, Springer, in press. Istvan Karsai and George Kampis 2010: Connected Fragmented Habitats Facilitate Coexistence, submitted. Wilensky, U. (1998). NetLogo Wolf Sheep Predation model. http://ccl.northwestern.edu/netlogo/models/WolfSheepPredation. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL. @#$#@#$#@ default true 0 Polygon -7500403 true true 150 5 40 250 150 205 260 250 airplane true 0 Polygon -7500403 true true 150 0 135 15 120 60 120 105 15 165 15 195 120 180 135 240 105 270 120 285 150 270 180 285 210 270 165 240 180 180 285 195 285 165 180 105 180 60 165 15 arrow true 0 Polygon -7500403 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150 box false 0 Polygon -7500403 true true 150 285 285 225 285 75 150 135 Polygon -7500403 true true 150 135 15 75 150 15 285 75 Polygon -7500403 true true 15 75 15 225 150 285 150 135 Line -16777216 false 150 285 150 135 Line -16777216 false 150 135 15 75 Line -16777216 false 150 135 285 75 bug true 0 Circle -7500403 true true 96 182 108 Circle -7500403 true true 110 127 80 Circle -7500403 true true 110 75 80 Line -7500403 true 150 100 80 30 Line -7500403 true 150 100 220 30 butterfly true 0 Polygon -7500403 true true 150 165 209 199 225 225 225 255 195 270 165 255 150 240 Polygon -7500403 true true 150 165 89 198 75 225 75 255 105 270 135 255 150 240 Polygon -7500403 true true 139 148 100 105 55 90 25 90 10 105 10 135 25 180 40 195 85 194 139 163 Polygon -7500403 true true 162 150 200 105 245 90 275 90 290 105 290 135 275 180 260 195 215 195 162 165 Polygon -16777216 true false 150 255 135 225 120 150 135 120 150 105 165 120 180 150 165 225 Circle -16777216 true false 135 90 30 Line -16777216 false 150 105 195 60 Line -16777216 false 150 105 105 60 car false 0 Polygon -7500403 true true 300 180 279 164 261 144 240 135 226 132 213 106 203 84 185 63 159 50 135 50 75 60 0 150 0 165 0 225 300 225 300 180 Circle -16777216 true false 180 180 90 Circle -16777216 true false 30 180 90 Polygon -16777216 true false 162 80 132 78 134 135 209 135 194 105 189 96 180 89 Circle -7500403 true true 47 195 58 Circle -7500403 true true 195 195 58 circle false 0 Circle -7500403 true true 0 0 300 circle 2 false 0 Circle -7500403 true true 0 0 300 Circle -16777216 true false 30 30 240 cow false 0 Polygon -7500403 true true 200 193 197 249 179 249 177 196 166 187 140 189 93 191 78 179 72 211 49 209 48 181 37 149 25 120 25 89 45 72 103 84 179 75 198 76 252 64 272 81 293 103 285 121 255 121 242 118 224 167 Polygon -7500403 true true 73 210 86 251 62 249 48 208 Polygon -7500403 true true 25 114 16 195 9 204 23 213 25 200 39 123 cylinder false 0 Circle -7500403 true true 0 0 300 dot false 0 Circle -7500403 true true 90 90 120 face happy false 0 Circle -7500403 true true 8 8 285 Circle -16777216 true false 60 75 60 Circle -16777216 true false 180 75 60 Polygon -16777216 true false 150 255 90 239 62 213 47 191 67 179 90 203 109 218 150 225 192 218 210 203 227 181 251 194 236 217 212 240 face neutral false 0 Circle -7500403 true true 8 7 285 Circle -16777216 true false 60 75 60 Circle -16777216 true false 180 75 60 Rectangle -16777216 true false 60 195 240 225 face sad false 0 Circle -7500403 true true 8 8 285 Circle -16777216 true false 60 75 60 Circle -16777216 true false 180 75 60 Polygon -16777216 true false 150 168 90 184 62 210 47 232 67 244 90 220 109 205 150 198 192 205 210 220 227 242 251 229 236 206 212 183 fish false 0 Polygon -1 true false 44 131 21 87 15 86 0 120 15 150 0 180 13 214 20 212 45 166 Polygon -1 true false 135 195 119 235 95 218 76 210 46 204 60 165 Polygon -1 true false 75 45 83 77 71 103 86 114 166 78 135 60 Polygon -7500403 true true 30 136 151 77 226 81 280 119 292 146 292 160 287 170 270 195 195 210 151 212 30 166 Circle -16777216 true false 215 106 30 flag false 0 Rectangle -7500403 true true 60 15 75 300 Polygon -7500403 true true 90 150 270 90 90 30 Line -7500403 true 75 135 90 135 Line -7500403 true 75 45 90 45 flower false 0 Polygon -10899396 true false 135 120 165 165 180 210 180 240 150 300 165 300 195 240 195 195 165 135 Circle -7500403 true true 85 132 38 Circle -7500403 true true 130 147 38 Circle -7500403 true true 192 85 38 Circle -7500403 true true 85 40 38 Circle -7500403 true true 177 40 38 Circle -7500403 true true 177 132 38 Circle -7500403 true true 70 85 38 Circle -7500403 true true 130 25 38 Circle -7500403 true true 96 51 108 Circle -16777216 true false 113 68 74 Polygon -10899396 true false 189 233 219 188 249 173 279 188 234 218 Polygon -10899396 true false 180 255 150 210 105 210 75 240 135 240 house false 0 Rectangle -7500403 true true 45 120 255 285 Rectangle -16777216 true false 120 210 180 285 Polygon -7500403 true true 15 120 150 15 285 120 Line -16777216 false 30 120 270 120 leaf false 0 Polygon -7500403 true true 150 210 135 195 120 210 60 210 30 195 60 180 60 165 15 135 30 120 15 105 40 104 45 90 60 90 90 105 105 120 120 120 105 60 120 60 135 30 150 15 165 30 180 60 195 60 180 120 195 120 210 105 240 90 255 90 263 104 285 105 270 120 285 135 240 165 240 180 270 195 240 210 180 210 165 195 Polygon -7500403 true true 135 195 135 240 120 255 105 255 105 285 135 285 165 240 165 195 line true 0 Line -7500403 true 150 0 150 300 line half true 0 Line -7500403 true 150 0 150 150 link true 0 Line -7500403 true 150 0 150 300 link direction true 0 Line -7500403 true 150 150 30 225 Line -7500403 true 150 150 270 225 pentagon false 0 Polygon -7500403 true true 150 15 15 120 60 285 240 285 285 120 person false 0 Circle -7500403 true true 110 5 80 Polygon -7500403 true true 105 90 120 195 90 285 105 300 135 300 150 225 165 300 195 300 210 285 180 195 195 90 Rectangle -7500403 true true 127 79 172 94 Polygon -7500403 true true 195 90 240 150 225 180 165 105 Polygon -7500403 true true 105 90 60 150 75 180 135 105 plant false 0 Rectangle -7500403 true true 135 90 165 300 Polygon -7500403 true true 135 255 90 210 45 195 75 255 135 285 Polygon -7500403 true true 165 255 210 210 255 195 225 255 165 285 Polygon -7500403 true true 135 180 90 135 45 120 75 180 135 210 Polygon -7500403 true true 165 180 165 210 225 180 255 120 210 135 Polygon -7500403 true true 135 105 90 60 45 45 75 105 135 135 Polygon -7500403 true true 165 105 165 135 225 105 255 45 210 60 Polygon -7500403 true true 135 90 120 45 150 15 180 45 165 90 sheep false 0 Rectangle -16777216 true false 166 225 195 285 Rectangle -16777216 true false 62 225 90 285 Rectangle -7500403 true true 30 75 210 225 Circle -7500403 true true 135 75 150 Circle -16777216 true false 180 76 116 square false 0 Rectangle -7500403 true true 30 30 270 270 square 2 false 0 Rectangle -7500403 true true 30 30 270 270 Rectangle -16777216 true false 60 60 240 240 star false 0 Polygon -7500403 true true 151 1 185 108 298 108 207 175 242 282 151 216 59 282 94 175 3 108 116 108 target false 0 Circle -7500403 true true 0 0 300 Circle -16777216 true false 30 30 240 Circle -7500403 true true 60 60 180 Circle -16777216 true false 90 90 120 Circle -7500403 true true 120 120 60 tree false 0 Circle -7500403 true true 118 3 94 Rectangle -6459832 true false 120 195 180 300 Circle -7500403 true true 65 21 108 Circle -7500403 true true 116 41 127 Circle -7500403 true true 45 90 120 Circle -7500403 true true 104 74 152 triangle false 0 Polygon -7500403 true true 150 30 15 255 285 255 triangle 2 false 0 Polygon -7500403 true true 150 30 15 255 285 255 Polygon -16777216 true false 151 99 225 223 75 224 truck false 0 Rectangle -7500403 true true 4 45 195 187 Polygon -7500403 true true 296 193 296 150 259 134 244 104 208 104 207 194 Rectangle -1 true false 195 60 195 105 Polygon -16777216 true false 238 112 252 141 219 141 218 112 Circle -16777216 true false 234 174 42 Rectangle -7500403 true true 181 185 214 194 Circle -16777216 true false 144 174 42 Circle -16777216 true false 24 174 42 Circle -7500403 false true 24 174 42 Circle -7500403 false true 144 174 42 Circle -7500403 false true 234 174 42 turtle true 0 Polygon -10899396 true false 215 204 240 233 246 254 228 266 215 252 193 210 Polygon -10899396 true false 195 90 225 75 245 75 260 89 269 108 261 124 240 105 225 105 210 105 Polygon -10899396 true false 105 90 75 75 55 75 40 89 31 108 39 124 60 105 75 105 90 105 Polygon -10899396 true false 132 85 134 64 107 51 108 17 150 2 192 18 192 52 169 65 172 87 Polygon -10899396 true false 85 204 60 233 54 254 72 266 85 252 107 210 Polygon -7500403 true true 119 75 179 75 209 101 224 135 220 225 175 261 128 261 81 224 74 135 88 99 wheel false 0 Circle -7500403 true true 3 3 294 Circle -16777216 true false 30 30 240 Line -7500403 true 150 285 150 15 Line -7500403 true 15 150 285 150 Circle -7500403 true true 120 120 60 Line -7500403 true 216 40 79 269 Line -7500403 true 40 84 269 221 Line -7500403 true 40 216 269 79 Line -7500403 true 84 40 221 269 wolf false 0 Rectangle -7500403 true true 195 106 285 150 Rectangle -7500403 true true 195 90 255 105 Polygon -7500403 true true 240 90 217 44 196 90 Polygon -16777216 true false 234 89 218 59 203 89 Rectangle -1 true false 240 93 252 105 Rectangle -16777216 true false 242 96 249 104 Rectangle -16777216 true false 241 125 285 139 Polygon -1 true false 285 125 277 138 269 125 Polygon -1 true false 269 140 262 125 256 140 Rectangle -7500403 true true 45 120 195 195 Rectangle -7500403 true true 45 114 185 120 Rectangle -7500403 true true 165 195 180 270 Rectangle -7500403 true true 60 195 75 270 Polygon -7500403 true true 45 105 15 30 15 75 45 150 60 120 x false 0 Polygon -7500403 true true 270 75 225 30 30 225 75 270 Polygon -7500403 true true 30 75 75 30 270 225 225 270 @#$#@#$#@ NetLogo 4.1 @#$#@#$#@ setup set grass? true repeat 75 [ go ] @#$#@#$#@ @#$#@#$#@ setup go count turtles @#$#@#$#@ @#$#@#$#@ default 0.0 -0.2 0 1.0 0.0 0.0 1 1.0 0.0 0.2 0 1.0 0.0 link direction true 0 Line -7500403 true 150 150 90 180 Line -7500403 true 150 150 210 180 @#$#@#$#@ 0 @#$#@#$#@