Herbivory and Plant Interspecific Competition
Model was written in NetLogo 6.2.2
•
Viewed 214 times
•
Downloaded 26 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
; Coded in 2022 by Lin Xiang; Last revised in 2022 by Lin Xiang (lxiang75@gmail.com; lin.xiang@uky.edu) ;; ;; If you mention this model in a publication, we ask that you include the citations below. ;; ;; Xiang, L. (2022). Herbivory and Plant Interspecific Competition. Department of STEM Education, University of Kentucky, Lexington, KY. ;; breed [plant1s plant1] breed [plant2s plant2] breed [animal1s animal1 ] breed [animal2s animal2 ] breed [legends legend] plant1s-own [ num-seed-1 erg-0] plant2s-own [ num-seed-2 erg-00] animal1s-own [erg-1 life-1] animal2s-own [erg-2 life-2] patches-own [] Globals [ running-avg-list1 running-avg-list2 running-avg-lista1 running-avg-lista2 mean-total-1 mean-total-2 mean-total-a1 mean-total-a2 ] to-report empty-patches ;find empty patches for growing a plant report patches with [pcolor >= 79 and pcolor <= 79.5 and not any? plant1s-here and not any? plant2s-here] end to setup clear-all setup-patches setup-legends add-plants1 add-plants2 add-rabbits add-mice set running-avg-list1 [] set running-avg-list2 [] set running-avg-lista1 [] set running-avg-lista2 [] reset-ticks end to setup-patches ask patches [set pcolor 79 + random-float 0.5] ask patches with [ pycor = max-pycor or pycor < 2] [set pcolor white] end to add-plants1 ask up-to-n-of number-of-plant1s empty-patches [sprout-plant1s 1 [set color 135 set shape "weed-1" set size 0.6 + random-float 0.4 set erg-0 10]] end to add-plants2 ask up-to-n-of number-of-plant2s empty-patches [sprout-plant2s 1 [set shape "plant-1" set size 0.6 + random-float 0.4 set erg-00 10]] end to add-rabbits create-animal1s number-of-rabbits [set color 36.5 set size 1 set erg-1 5 + random 10 set shape "rabbit-1" setxy 1 + random (max-pxcor - 1) 2 + random (max-pycor - 2) ] end to add-mice create-animal2s number-of-mice [set color 34.5 set size 0.65 set erg-2 5 + random 10 set shape "mouse" setxy 1 + random (max-pxcor - 1) 2 + random (max-pycor - 2) ] end ;;;;;;;;;;;;;;;;;;;;; ;; GO PROCEDURE ;; ;;;;;;;;;;;;;;;;;;;;; to go every 0.1[ if ticks >= Years [stop] move feeding plant-reproduction death find-running-avg tick ] end to move if any? animal1s [ask animal1s [ifelse life-1 >= 14 [die] [set life-1 life-1 + 1] ;set animals' life-span right random 360 if [pcolor] of patch-at dx dy <= 79.5 and [pcolor] of patch-at dx dy >= 79 [fd 1 if ycor < 2 [set ycor 2] set erg-1 erg-1 - 1] ;stay within the blue area if erg-1 <= 0 [die]]] ;die when no energy if any? animal2s [ask animal2s [ifelse life-2 >= 14 [die] [set life-2 life-2 + 1] ;set animals' life-span right random 360 if [pcolor] of patch-at dx dy <= 79.5 and [pcolor] of patch-at dx dy >= 79 [fd 1 if ycor < 2 [set ycor 2] set erg-2 erg-2 - 1] ;stay within the blue area if erg-2 <= 0 [die]]] ;die when no energy end to feeding (ifelse any? animal1s and not any? animal2s ;when only animal1 [feeding-1] any? animal2s and not any? animal1s ;when only animal2 [feeding-2] any? animal1s and any? animal2s ;when both animals, [ifelse random 2 = 0 ;randomize the feeding [feeding-1 feeding-2] [feeding-2 feeding-1]] ) end to feeding-1 ;feed and reproduce ask animal1s [ if any? plant1s-here [ let food one-of plant1s-here set erg-1 erg-1 + [erg-0] of food ask food [die]]] ask animal1s [ if erg-1 > 20 [if random 100 < 20 [hatch 1 [set erg-1 5 set life-1 0] set erg-1 erg-1 - 10]]] end to feeding-2 ;feed and reproduce ask animal2s [ if any? plant2s-here [ let food one-of plant2s-here set erg-2 erg-2 + [erg-00] of food ask food [die]]] ask animal2s [ if erg-2 > 20 [if random 100 < 20 [hatch 1 [set erg-2 5 set life-2 0] set erg-2 erg-2 - 10]]] end to plant-reproduction (ifelse any? plant1s and not any? plant2s [reproduce-1] any? plant2s and not any? plant1s [reproduce-2] any? plant1s and any? plant2s [ ifelse random 2 = 0 [reproduce-1 reproduce-2] [reproduce-2 reproduce-1]] ) end to reproduce-1 if any? plant1s [ask plant1s [set num-seed-1 plant1-seeds ;- 1 ask up-to-n-of num-seed-1 neighbors with [pcolor <= 79.5 and pcolor >= 79 and not any? plant1s-here and not any? plant2s-here] [sprout-plant1s 1 [set shape "weed-1" set size 0.6 + random-float 0.4 set erg-0 10]] ]] end to reproduce-2 if any? plant2s [ask plant2s [set num-seed-2 plant2-seeds ;- 1 ask up-to-n-of num-seed-2 neighbors with [pcolor <= 79.5 and pcolor >= 79 and not any? plant1s-here and not any? plant2s-here] [sprout-plant2s 1 [set shape "plant-1" set size 0.6 + random-float 0.4 set erg-00 10]] ]] end to death ask plant1s [if random 100 < 40 [die]] ;a mortality of 35-45% is needed for competition pattern ask plant2s [if random 100 < 40 [die]] end to find-running-avg ;find the 5-year running averages (ifelse ticks < 10 [set running-avg-list1 lput (count plant1s) running-avg-list1 set mean-total-1 mean running-avg-list1 set running-avg-list2 lput (count plant2s) running-avg-list2 set mean-total-2 mean running-avg-list2 set running-avg-lista1 lput (count animal1s) running-avg-lista1 set mean-total-a1 mean running-avg-lista1 set running-avg-lista2 lput (count animal2s) running-avg-lista2 set mean-total-a2 mean running-avg-lista2] [set running-avg-list1 lput count plant1s running-avg-list1 set running-avg-list1 remove-item 0 running-avg-list1 set mean-total-1 mean running-avg-list1 set running-avg-list2 lput count plant2s running-avg-list2 set running-avg-list2 remove-item 0 running-avg-list2 set mean-total-2 mean running-avg-list2 set running-avg-lista1 lput count animal1s running-avg-lista1 set running-avg-lista1 remove-item 0 running-avg-lista1 set mean-total-a1 mean running-avg-lista1 set running-avg-lista2 lput count animal2s running-avg-lista2 set running-avg-lista2 remove-item 0 running-avg-lista2 set mean-total-a2 mean running-avg-lista2]) end to setup-legends create-legends 9 ask legend 0 [set shape "weed-11" set size 1 setxy 1.5 0.75] ask legend 1 [set shape "rabbit-1" set color 36.5 set size 1.25 setxy 3.5 0.75] ask legend 2 [set shape "plant-11" set size 1 setxy 9.5 0.75] ask legend 3 [set shape "mouse" set color 34.5 set size 1 setxy 7.5 0.75] ask legend 4 [set shape "arrow-1" set color 136 set size 1 set heading 80 setxy 2.5 0.75] ask legend 5 [set shape "blank" set color 136 set size 1.5 set label "Rabbits feed on plant1s." set label-color 0 set heading 75 setxy 3.7 0.5] ask legend 6 [set shape "arrow-1" set color 136 set size 1 set heading -80 setxy 8.5 0.75] ask legend 7 [set shape "blank" set color 136 set size 1.5 set label "Mice feed on plant2s." set label-color 0 set heading 75 setxy 9.5 0.5] ask legend 8 [set shape "line" set color 8 set size 13 set heading 90 setxy 5.5 1.5] end
There are 7 versions of this model.
This model does not have any ancestors.
This model does not have any descendants.