Carrying Capacity
Model was written in NetLogo 6.2.0
•
Viewed 455 times
•
Downloaded 34 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
;; Carrying Capacity model. ;; ;; Coded in 2019 by Lin Xiang; Last revised in 2021 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. (2019). Carrying Capacity. Department of STEM Education, University of Kentucky, Lexington, KY. ;; ;;----------------------------------------- ;;CREATIVE COMMONS LICENSE ;;This code is distributed by Lin Xiang under a Creative Commons License: ;;Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) ;;https://creativecommons.org/licenses/by-sa/4.0/ ;; ;;----------------------------------------- globals [Available-grass total-grass h-size] Breed [elks elk] breed [wolves wolf] breed [rabbits rabbit] turtles-own [erg] ;------------------------------------; ; SETUP PROCEDURES ; ;------------------------------------; to setup ca setup-habitat ;setup habitat ask patches with [pcolor = 53] ;create elk [sprout-elks 1 [ set shape "elk" set size 0.75 set color 37.5 setup-position set erg 30]] set infinite-grass? false if number-of-wolves != 0 [setup-wolves] if number-of-rabbits != 0 [setup-rabbits] RESET-TICKS end ;------------------------------------; ; GO PROCEDURES ; ;------------------------------------; to go tick competition eat death reproduce predation update-habitat-size regrow-grass if count elks >= 10000 [ user-message "There are more than 10,000 elks now. They have taken over this world!" stop] if count elks <= 0 [user-message "All elks die." stop] end ;------------------------------------; ; SUB-PROCEDURES ; ;------------------------------------; to setup-habitat ask patches [set pcolor 94] ask patches with [abs pxcor <= habitat-size and abs pycor <= habitat-size] [set pcolor 53] set total-grass count patches with [pcolor = 53] set h-size habitat-size end to setup-position setxy (-1 * habitat-size) + random-float (habitat-size * 2) (-1 * habitat-size) + random-float (habitat-size * 2) end to move ifelse [pcolor] of patch-at dx dy = 94 [setup-position][fd 1 rt random 360] end to eat ask elks [ move set erg erg - 1 ifelse infinite-grass? = false [ if pcolor = 53 [set erg erg + 3 set pcolor 0]][set erg erg + 3] ] end to death ask elks [ if erg <= 0 [die] ] ask turtles [ if pcolor = 94 [die] ] end to reproduce ask elks [ if erg >= 60 [hatch 1 [set erg 30] set erg erg - 30 setup-position] ] end to regrow-grass ask patches [ if pcolor = 0 [if random 100 < grass-growth-rate [set pcolor 53] ] ] set Available-grass count patches with [pcolor = 53] / total-grass end to setup-wolves create-wolves number-of-wolves [ set shape "wolf" set color 32 set size 1 set erg 20 setup-position] end to predation ifelse number-of-wolves = 0 [ask wolves [die]] [let wolf-number count wolves if wolf-number != number-of-wolves [ask wolves [die] setup-wolves] ask wolves [ move let prey one-of elks-here if prey != nobody [ask prey [die]] ]] end to setup-rabbits create-rabbits number-of-rabbits [set shape "rabbit1" set color 9 set size 0.5 setup-position] end to competition ifelse number-of-rabbits = 0 [ask rabbits [die]] [let rabbit-number count rabbits if rabbit-number != number-of-rabbits [ask rabbits [die] setup-rabbits] ask rabbits [ move if pcolor = 53 [set pcolor 0] ]] end to update-habitat-size if h-size != habitat-size [ clear-patches setup-habitat] end to-report grass-growth-rate report -0.25 * (temperature ^ 2) + 12.5 * temperature - 56.25 end
There are 4 versions of this model.
This model does not have any ancestors.
This model does not have any descendants.