Community Environment
Model was written in NetLogo 6.2.0
•
Viewed 698 times
•
Downloaded 33 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Info tab cannot be displayed because of an encoding error
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
globals [ rain-countdown rain-countdown-middle rain-countdown-greypatch sediment pollution relationship-energy run-number ready-persons-uphill-initial uphill-projects mud-patch-pollution hard-patch-pollution hard-patch-eroder ] turtles-own [ energy stop-countdown ] patches-own [eroded-land-to-grass-countdown eroded-land-to-hard-land-countdown hard-land-to-grass-countdown ] breed [ready-persons ready-person] breed [not-ready-persons not-ready-person] breed [erosions erosion] breed [flowers flower] breed [erosion-middles erosion-middle] breed [erosion-greypatchs erosion-greypatch] breed [monarchs monarch] breed [dragonflies dragonfly] breed [mayflies mayfly] to setup-keep clear-turtles clear-patches set run-number run-number + 1 setup-world end to setup-new ca set run-number 1 setup-world end to setup-world setup-ready-persons setup-not-ready-persons setup-erosions setup-dragonflies setup-mayflies reposition count-ready-persons-uphill set sediment 0 set pollution 0 set rain-countdown 500 set rain-countdown-middle 500 set relationship-energy 0 set mud-patch-pollution 0 set hard-patch-pollution 0 set hard-patch-eroder 0 set uphill-projects 0 ask patches [ set eroded-land-to-grass-countdown eroded-land-to-grass-countdown + 750 set eroded-land-to-hard-land-countdown eroded-land-to-hard-land-countdown + 1000 set hard-land-to-grass-countdown hard-land-to-grass-countdown + 750] ask turtles [ set stop-countdown 0 ] ask patches [ if pycor <= -15 ;-15 is the threshold between the blue patches and the green patches [set pcolor blue ] ;The blue patches represent a body of water. if pycor > -15 [set pcolor green ] ;The green patches represent land that has vegetation with shallower root structure (like lawn) or have roots in the ground only part of the year (so as seasonal crops but no cover crops. Therefore, these conditions provide only modest filtration benefits. if (distancexy (0.3 * max-pycor) 0) < hard-surface * 2 [ set pcolor grey ] ] reset-ticks end to setup-ready-persons create-turtles individual-readiness * 2 [ setxy random-xcor random-ycor set size 2.15 set breed ready-persons set shape "person" set color yellow set energy 40 ;assigning energy ] end to setup-not-ready-persons create-turtles 10 - individual-readiness * 2 [ setxy random-xcor random-ycor set size 2.15 set breed not-ready-persons set shape "person" set color red set energy 5 ;assigning energy ] end to reposition ask ready-persons [if ycor < -15 [set ycor 0] ] ask ready-persons [if ycor > 18 [set ycor 15] ] ask not-ready-persons [if ycor < -15 [set ycor 0] ] ask not-ready-persons [if ycor > 18 [set ycor 15] ] end to setup-erosions ;sets up the erosion blue circles that begin uphill ;middle of the landscape erosion rainfall will begin after the first cycle ifelse downpours = false ;;if downpours are false/the else part is dry-spells are true [these two next blocks of code are identical and must be left as two] ; [ ifelse dry-spells = false [create-turtles rainfall [ ;if dry-spells are false setxy random-xcor 20 set size 0.5 set color blue set heading 90 set breed erosions set shape "circle"]] [create-turtles rainfall [ ;if dry spells are true (else) setxy random-xcor 20 set size 0.5 set color blue set heading 90 set breed erosions set shape "circle"]] ] ;if downpours are false/the else part is dry-spells are true [These two next blocks of code are identical and must be left as two] [ifelse dry-spells = false [create-turtles rainfall [ ;if dry-spells are false setxy random-xcor 20 set size 0.5 set color blue set heading 90 set breed erosions set shape "circle"]] [create-turtles rainfall [ ;if dry spells are true (else) setxy random-xcor 20 set size 0.5 set color blue set heading 90 set breed erosions set shape "circle"]] ] end to setup-dragonflies create-turtles 3 [ set xcor random-xcor set ycor -17 set size 2.2 set breed dragonflies set shape "dragonfly"] end to setup-mayflies create-turtles 3 [ set xcor random-xcor set ycor -17 set size 2.2 set breed mayflies set shape "mayfly"] end to count-ready-persons-uphill set ready-persons-uphill-initial 0 ask ready-persons [ if pycor > 11 [ set ready-persons-uphill-initial ready-persons-uphill-initial + 1 ]] end to go ;asks turtles to move and to take action. Asks patches to grow grass ask ready-persons [ move plant-flowers-ready plant-flowers-ready-hardland cooperate collapse-community ;When water quality degrades to 8000, the water turns grey, and at 9000, all the people turn grey. ] ask not-ready-persons [ move plant-flowers-not-ready plant-flowers-not-ready-hardland cooperate2 collapse-community ] ask erosions [ move-erosions erode-land stop-erosion pollute-water pickup-pollution birth-hardpatch-eroders birth-hardland-eroders ] ask erosion-middles [ move-erosions erode-land stop-erosion pollute-water pickup-pollution birth-hardpatch-eroders ] ask patches [ grow-grass-or-harden-land rebirth-erosions rebirth-erosion-middles birth-dragonflies birth-mayflies collapse-water hard-land-to-grass ] ask monarchs [ wiggle death-monarch ] ask dragonflies [ water-wiggle death-dragonfly ] ask mayflies [ water-wiggle death-mayfly ] set rain-countdown rain-countdown - 1 set rain-countdown-middle rain-countdown-middle - 1 set rain-countdown-greypatch rain-countdown-greypatch - 1 ;Constant subtraction rate to balance pollution as water flows over the green patches because these vegetated areas do contribute some to slowing/filtering water. There is no subtraction for going over a hard surface. if hard-patch-pollution + mud-patch-pollution + pollution > 0 [ set mud-patch-pollution mud-patch-pollution - .33] if hard-patch-pollution + mud-patch-pollution + pollution < 0 [ set mud-patch-pollution 0 set hard-patch-pollution 0 set pollution 0] if sediment < 0 [ set sediment 0] tick end to move ;Move function for persons as well as the stop-countdown function to halt the model at 8500 ticks. ifelse stop-countdown > 8500 [rt 0 lt 0 fd 0 user-message (word "You have reached the end of this scenario!" "Click HALT to try another;" " then press setup-keep or setup-new." ) ] [rt 0.43 * community-collaboration * 2 ; Community-collaboration alters the angle of moevment, which narrows or expands persons' sphere of influence. w/.75 range at 3 allows about 1/2 the range of movement. lt 5 if pycor = -15 ; turns people around when they touch the body of water [ fd 0 set heading heading + 180 ] if pycor = 19 ; turns people around when they move too to the top edge of the landscape; The world is coded to "wrap" right and left only, not top and bottom, because moving agents who would wrap at the top would end up in the water below.] [ fd 0 set heading heading + 180 ] fd 0.15 set stop-countdown stop-countdown + 1] end to move-erosions ;move function for erosions ifelse pcolor = grey [set heading 180 fd 0.3] [ifelse pcolor = 35.6 [set heading 180 fd 0.3] ;this is the movement of rain over normal green patches [fd 0.075 right random 35 left random 35 if heading >= 270 [set heading 180] if heading <= 90 [set heading 180]]] end to wiggle rt random 40 lt random 40 fd 0.1 end to water-wiggle rt random 8 lt random 8 if pycor >= -15 ; These next two units of movement code limit the water insects to the blue patches only. [ fd 0 set ycor -16 set heading heading + 180 ] if pycor = -20 ; [ fd 0 set ycor -19 set heading heading + 180 ] fd 0.01 end to grow-grass-or-harden-land ;countdown for regrowing grass ifelse dry-spells = false ;The else component of this function (the second unit of code below) is that dry-spells are true. [if pcolor = brown [ ifelse eroded-land-to-grass-countdown <= 0 [ set pcolor green set eroded-land-to-grass-countdown 750 ;Setting the regrowth of grass countdown to 750 ensures that this countdown is slower than that of the rain. set sediment sediment - 1 set mud-patch-pollution mud-patch-pollution - .1] ;The green patches have vegetation with shallower root structure (like lawn) or have roots in the ground only part of the year (so as seasonal crops but no cover crops. Therefore, these conditions provide only modest filtration benefits. [ set eroded-land-to-grass-countdown eroded-land-to-grass-countdown - 1 ]]] [if pcolor = brown [ ifelse eroded-land-to-hard-land-countdown <= 0 [ set pcolor 35.6 set eroded-land-to-hard-land-countdown 1000 ; set sediment sediment + 3 ; When runoff passes over hardened land, it cannot infiltrate and thus erodes and picks up pollutants faster (see next line of code). set mud-patch-pollution mud-patch-pollution + .2] [ set eroded-land-to-hard-land-countdown eroded-land-to-hard-land-countdown - 1]]] end to hard-land-to-grass if pcolor = 35.6 [ ifelse hard-land-to-grass-countdown <= 0 [ set pcolor green set hard-land-to-grass-countdown 750 set sediment sediment - 3 set mud-patch-pollution mud-patch-pollution - .1] [ set hard-land-to-grass-countdown hard-land-to-grass-countdown - 1]] end to erode-land ;erosion function that the eroders use to turn the patches from green to brown and adds sediment when land is hardened if pcolor = green [ set pcolor brown set sediment sediment + 1 ] if pcolor = 35.6 [ set sediment sediment + 2] end to plant-flowers-ready ;For a "ready" person to plant a flower, it takes 20 units of energy, and planting can be done on eroded land only. if energy >= 20 [ if pcolor = brown [ ;If so, it then asks if they are on a brown patch, set pcolor 53 ;If so, it sets the patch dark green and subtracts 20 energy. The green patch is the signal that this patch has a flower agent on it, thus allowing the stop-erosion function included below.] set energy energy - 20 set sediment sediment - 1.2 set mud-patch-pollution mud-patch-pollution - 2 ; see plant-flowers-ready2 for note if pxcor < -11 [ set uphill-projects uphill-projects + 1] hatch 1 [ set breed flowers set shape "flower" set size 1.9 set color 127 ]]] if energy >= 61 [ ;caps amount of energy that a person can have, which is important to avoid count going too high when agents occasionally get stuck together set energy 60 ] end to plant-flowers-ready-hardland ;For a "ready" person to plant a flower on hardened soil, it takes 30 units of energy, and planting can be done on eroded land only. if energy >= 30 [ if pcolor = 35.6 [ ;if so, it then asks if they are on a light-brown hardland patch, set pcolor 53 ;if so, it sets the patch dark green and subtracts 20 energy set energy energy - 30 set sediment sediment - 3 set mud-patch-pollution mud-patch-pollution - 2 ; see plant-flowers-ready2 for note if pxcor < -11 [ set uphill-projects uphill-projects + 1] hatch 1 [ set breed flowers set shape "flower" set size 1.9 set color 127 ]]] if energy >= 61 [ ;caps amount of energy that a person can have, which is important to avoid count going too high when agents occasionally get stuck together set energy 60 ] end to plant-flowers-not-ready ; This function is for persons who were not ready but who have become "now ready." if energy >= 40 [ if pcolor = brown [ ;if so, it then asks if they are on a light-brown hardland patch, set pcolor 53 ;if so, it sets the patch dark green and subtracts 40 energy set energy energy - 40 set sediment sediment - 1.2 set mud-patch-pollution mud-patch-pollution - 2 ; the value for the perennial planting is much higher when it stops erosion set shape "person now ready" if pxcor < -11 [ set uphill-projects uphill-projects + 1 ] hatch 1 [ set breed flowers set shape "flower" set size 1.9 set color 127 ]]] if energy >= 61 [ set energy 60 ] end to plant-flowers-not-ready-hardland ;This function is for persons who were not ready but who have become "now ready." For a "now-ready" person to plant a flower on hardened soil, it takes 55 units of energy, and planting can be done on eroded land only if energy >= 55 [ if pcolor = 35.6 [ ;if so, it then asks if they are on a light brown hardland patch, set pcolor 53 ;if so, it sets the patch dark green and subtracts 40 energy set energy energy - 55 set sediment sediment - 3 set mud-patch-pollution mud-patch-pollution - 2 ; the value for the perennial planting is much higher when it stops erosion set shape "person now ready" if pxcor < -11 [ set uphill-projects uphill-projects + 1 ] hatch 1 [ set breed flowers set shape "flower" set size 1.9 set color 127 ]]] if energy >= 61 [ set energy 60 ] end to cooperate ;Allows ready persons to give other persons energy when they interact directly with (cooperate) each other. Ready persons give and receive more energy than not-ready persons. ask not-ready-persons in-radius 0.9 [ set energy energy + 5 fd 0 set heading heading + 180 set relationship-energy relationship-energy + 1 move ] ask other ready-persons in-radius 0.9 [ set energy energy + 30 fd 0 set heading heading + 45 set relationship-energy relationship-energy + 10 move ] end to cooperate2 ;Allows not-ready persons to give other persons energy when they interact directly (cooperate) with each other. Not-ready persons give and receive less energy than ready persons. ask ready-persons in-radius 0.9 [ set energy energy + 5 fd 0 set heading heading + 145 set relationship-energy relationship-energy + 5 move ] ask other not-ready-persons in-radius 0.9 [ set energy energy + 1 fd 0 set heading heading + 180 set relationship-energy relationship-energy + 1 move ] end to stop-erosion if pcolor = 53 [ set sediment sediment - 1.2 ; perennial plantings are much more effective than grass; need more precise value set mud-patch-pollution mud-patch-pollution - 3.5 die ] end to rebirth-erosions if rain-countdown <= 0 [ ifelse dry-spells = false ;dry spells = off [if count flowers > sediment [ if count flowers < 225 [ sprout 1 [ ; set breed monarchs set size 1.5 set shape "monarch" set color 25 set energy 40 ;To indicate that pollinators support ecosystem health, each monarch plants 2 flowers when it is "sprouted." setxy random-xcor random-ycor]]]] ;dry spells = on [if count flowers > 90 [ if count flowers < 225 [ sprout 1 [ ; set breed monarchs set size 1.5 set shape "monarch" set color 25 set energy 40 ;To indicate that pollinators support ecosystem health, each monarch plants 2 flowers when it is "sprouted." setxy random-xcor random-ycor]]]] ifelse downpours = false ;if downpours are false ;change the beginning to just depend on downpours with one ifelse statement and use the ifelse statements here to change the middle erosions code [ ifelse dry-spells = false ;if = false ;dowpours OFF ;dry-spells OFF [sprout rainfall [ set breed erosions set shape "circle" set color blue set size 0.5 setxy random-xcor 20] set rain-countdown 500 ] ;else = true ;dowpours OFF ;dry-spells ON [if rainfall = 5 [ sprout rainfall [ set breed erosions set shape "circle" set color blue set size 0.5 setxy random-xcor 20 set rain-countdown 750]] if rainfall = 4 [ sprout rainfall [ set breed erosions set shape "circle" set color blue set size 0.5 setxy random-xcor 20 set rain-countdown 750]] if rainfall = 3 [ sprout rainfall [ set breed erosions set shape "circle" set color blue set size 0.5 setxy random-xcor 20 set rain-countdown 750]] if rainfall = 2 [ sprout rainfall [ set breed erosions set shape "circle" set color blue set size 0.5 setxy random-xcor 20 set rain-countdown 750]] if rainfall = 1 [ sprout rainfall [ set breed erosions set shape "circle" set color blue set size 0.5 setxy random-xcor 20 set rain-countdown 750]] ]] ;if downpours are true (else) ;downpours ON ;dry-spells OFF [ifelse dry-spells = false [sprout (rainfall * random 3) [ set breed erosions set shape "circle" set color blue set size 0.5 setxy random-xcor 20] set rain-countdown 250 ] ;downpours ON ;dry-spells ON [if rainfall = 5 [ sprout rainfall * random 3 [ set breed erosions set shape "circle" set color blue set size 0.5 setxy random-xcor 20 set rain-countdown 750 ]] if rainfall = 4 [ sprout rainfall * random 3 [ set breed erosions set shape "circle" set color blue set size 0.5 setxy random-xcor 20 set rain-countdown 750 ]] if rainfall = 3 [ sprout rainfall * random 3 [ set breed erosions set shape "circle" set color blue set size 0.5 setxy random-xcor 20 set rain-countdown 750 ]] if rainfall = 2 [ sprout rainfall * random 3 [ set breed erosions set shape "circle" set color blue set size 0.5 setxy random-xcor 20 set rain-countdown 750 ]] if rainfall = 1 [ sprout rainfall * random 3 [ set breed erosions set shape "circle" set color blue set size 0.5 setxy random-xcor 20 set rain-countdown 750]] ] ]] end to rebirth-erosion-middles if rain-countdown-middle <= 0 [ ifelse downpours = false ;downpours OFF ;dry-spells OFF [ ifelse dry-spells = false [sprout rainfall [ set breed erosion-middles set shape "circle" set color blue set size 0.5 set xcor random-xcor set ycor random-ycor set rain-countdown-middle 500]] ;downpours OFF ;dry-spells ON [if rainfall = 5 [ sprout rainfall [ set breed erosion-middles set shape "circle" set color blue set size 0.5 set xcor random-xcor set ycor random-ycor set rain-countdown-middle 750 ]] if rainfall = 4 [ sprout rainfall [ set breed erosion-middles set shape "circle" set color blue set size 0.5 set xcor random-xcor set ycor random-ycor set rain-countdown-middle 750 ]] if rainfall = 3 [ sprout rainfall [ set breed erosion-middles set shape "circle" set color blue set size 0.5 set xcor random-xcor set ycor random-ycor set rain-countdown-middle 750 ]] if rainfall = 2 [ sprout rainfall [ set breed erosion-middles set shape "circle" set color blue set size 0.5 set xcor random-xcor set ycor random-ycor set rain-countdown-middle 750 ]] if rainfall = 1 [ sprout rainfall [ set breed erosion-middles set shape "circle" set color blue set size 0.5 set xcor random-xcor set ycor random-ycor set rain-countdown-middle 750 ]] ] ] ;if downpours are true (else) ;downpours ON ;dry-spells OFF [ifelse dry-spells = false [sprout (rainfall * random 3) [ set breed erosion-middles set shape "circle" set color blue set size 0.5 set xcor random-xcor set ycor random-ycor set rain-countdown-middle 250]] ;downpours ON ;dry-spells ON [if rainfall = 5 [ sprout rainfall * random 3 [ set breed erosion-middles set shape "circle" set color blue set size 0.5 set xcor random-xcor set ycor random-ycor set rain-countdown-middle 750]] if rainfall = 4 [ sprout rainfall * random 3 [ set breed erosion-middles set shape "circle" set color blue set size 0.5 set xcor random-xcor set ycor random-ycor set rain-countdown-middle 750]] if rainfall = 3 [ sprout rainfall * random 3 [ set breed erosion-middles set shape "circle" set color blue set size 0.5 set xcor random-xcor set ycor random-ycor set rain-countdown-middle 750]] if rainfall = 2 [ sprout rainfall * random 3 [ set breed erosion-middles set shape "circle" set color blue set size 0.5 set xcor random-xcor set ycor random-ycor set rain-countdown-middle 750]] if rainfall = 1 [ sprout rainfall * random 3 [ set breed erosion-middles set shape "circle" set color blue set size 0.5 set xcor random-xcor set ycor random-ycor set rain-countdown-middle 750]] ] ] ] end to birth-mayflies if count mayflies < 3 [ if mud-patch-pollution + hard-patch-pollution + pollution <= 350 [ sprout 3 [ ; brings back mayflies when water pollution improves set xcor 17 set ycor random-ycor set size 2.2 set breed mayflies set shape "mayfly"] ]] end to birth-dragonflies if count dragonflies < 3 [ if mud-patch-pollution + hard-patch-pollution + pollution <= 750 [ sprout 3 [ ; brings back dragonflies when water pollution improves set xcor 17 set ycor random-ycor set size 2.2 set breed dragonflies set shape "dragonfly"] ]] end to pickup-pollution ; changes the amount of pollution picked up, depending on whether the surface is eroded soil, hard surface, or dry/hardened land. if pcolor = brown [ set mud-patch-pollution mud-patch-pollution + 0.17 ] if pcolor = grey [ set hard-patch-pollution hard-patch-pollution + 2.5 ]; Runoff over pavement is 15-20 times more than over such vegetated surfaces as traditional lawn. if pcolor = 35.6 [ set hard-patch-pollution hard-patch-pollution + 3.5 ] if count flowers > 70 [ set pollution pollution - .1] ;This subtraction included to acknowledge that only 140 flowers are needed to allow significant improvement in water quality/reduce runoff. According to the Prairie Strips project, putting on 10% of agricultural land in prairie strips offers dramatic reduction. end to pollute-water if pcolor = blue [ set pollution pollution + .18 die] end to birth-hardpatch-eroders ;spawns larger-sized eroder on hard patch to show lack of filtration on hard patch if dry-spells = false [ if pcolor = grey [ set size 1.5 ] if pycor <= -15 [ die ] ] if dry-spells = true [ if pcolor = grey [ set size 1.5 ] if patch-ahead 1 = brown [ set size 1.5 ] if pycor <= -15 [ die ] ] end to birth-hardland-eroders if dry-spells = false [ if pcolor = 35.6 [ set size 1.0 ] if pycor <= -15 [ die ] ] if dry-spells = true [ if pcolor = 35.6 [ set size 1.0 ] if patch-ahead 1 = brown [ set size 1.0 ] if pycor <= -15 [ die ] ] end to death-monarch if mud-patch-pollution + hard-patch-pollution + pollution >= 9000 [ ;Monarchs die once the water has collapsed. die ] end to death-mayfly ;Mayflies will die before dragonflies because mayflies have a low Pollution Tolerance Value if mud-patch-pollution + hard-patch-pollution + pollution > 300 [ ;Threshold is higher for rebirth because ecosystem needs to improve beyond the level when this species first died off.] die ] end to death-dragonfly ;Dragonflies survive longer than mayflies because dragonflies have a higher Pollution Tolerance Value. if mud-patch-pollution + hard-patch-pollution + pollution > 700 [ ;Threshold is higher for rebirth because ecosystem needs to improve beyond the level when this species first died off.] flushed out die ] end to collapse-community if mud-patch-pollution + hard-patch-pollution + pollution >= 9000 [ set color 3 set shape "person" ] end to collapse-water if mud-patch-pollution + hard-patch-pollution + pollution >= 8000 [ if pycor <= -15 [ set pcolor 3 ]] end
There are 3 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Community Environment.png | preview | Preview for 'Community Environment' | about 3 years ago, by Linda Shenk | Download |
This model does not have any ancestors.
This model does not have any descendants.