Konza Consumers

No preview image

1 collaborator

Default-person Peggy Schultz (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 6.1.1 • Viewed 56 times • Downloaded 2 times • Run 0 times
Download the 'Konza Consumers' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


WHAT IS IT?

This model explores the stability of the consumer producer ecosystems in the Serengetti related to two primary consumers (Buffalo and Wildebeest) that have an overlapping range they graze in, for part of the year.

HOW IT WORKS

HOW TO USE IT

  1. Adjust the slider parameters (see below), or use the default settings.

  2. Press the SETUP button.

  3. Press the GO button to begin the model run.

THINGS TO NOTICE

THINGS TO TRY

EXTENDING THE MODEL

NETLOGO FEATURES

RELATED MODELS

Wolf Sheep Predation and Rabbits Weeds Grass are other examples of interacting predator/prey populations with different rules.

CREDITS AND REFERENCES

Based on ihub model in How Do Small Changes Make Big Impacts on Ecosystems?

This model is part of HS Ecosystems storyline, sponsored by funding from the Moore Foundation.

modified by Luisa Garcia, Pam Lucas and Peggy Schultz

HOW TO CITE

If you mention this model or the NetLogo software in a publication, we ask that you include the citations below.

For the model itself:

  • Novak, M. and Penuel, W. (2017). Serengetti Consumers model.

Please cite the NetLogo software as:

COPYRIGHT AND LICENSE

Copyright 2015 Uri Wilensky.

CC BY-NC-SA 3.0

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at uri@northwestern.edu.

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

globals [
  bison-stride                ;; how much a bison moves in each simulation step
  bison-size                  ;; the size of the shape for a bison
  bison-reproduce-age         ;; age at which bison reproduces
  max-bison-age
  min-reproduce-energy-bison  ;; how much energy, at minimum, bison needs to reproduce
  max-bison-offspring        ;; max offspring a bison can have

  cattle-stride                ;; how much a bison moves in each simulation step
  cattle-size                  ;; the size of the shape for a bison
  cattle-reproduce-age         ;; age at which bison reproduces
  max-cattle-age
  min-reproduce-energy-cattle  ;; how much energy, at minimum, bison needs to reproduce
  max-cattle-offspring           ;; max offspring a bison can have


  max-grasses-energy          ;; the maximum amount of energy a plant in a patch can accumulate
  grass-level               ;; a measure of the amount of grass currently in the ecosystem
  grass-energy

  food-bison-eat
  food-cattle-eat

  rain-timer
  where-rain-band-is

  bison-color
  cattle-color
  grass-color
  dirt-color
  disease-age
  disease-color
  grazers
  rain-band-width
  coefficient-a
  sprout-delay-time
  region-boundaries
  speed-seasons
  rock-color
  bison-migrate?

  constant-simulation-length?
  cattle-migrate?    ;;we changed this PS
    ;;We changed this
]

breed [rocks rock]
breed [grasses grass]
breed [dividers divider]                 ;; dummy turtles that separate the view in regions
breed [disease-markers disease-marker]   ;; visual cue, red "X" that bison has a disease and will die
breed [bison a-bison]
breed [cattle a-cattle]

breed [embers ember]                     ;; visual cue that a grass patch is on fire
breed [disruptions disruption]           ;; dummy turtles that record the disruption events

breed [clouds cloud]
breed [rain-lines rain-line]
breed [rain-drops rain-drop]

bison-own [
  energy
  current-age
  max-age
  female?
  #-offspring
]

cattle-own [
  energy
  current-age
  max-age
  female?
  #-offspring
]

patches-own [
  fertile?
  plant-energy
  countdown
  region
  rain-level
]

grasses-own [

]

embers-own [
 current-age
]

disease-markers-own [
  current-age
]

rain-drops-own [current-age]

disruptions-own [
  disruption-region         ;; the region in which the disruption happened
  disruption-tick           ;; the tick at which the disruption happened
  disruption-description    ;; "infected bison", "added more bison" or "started a wild fire"
]

to startup
  setup-regions 3
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; setup procedures ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to setup

  clear-all

  set constant-simulation-length? false

  set bison-size 1.4
  set bison-stride 0.25
  set bison-reproduce-age 100
  set min-reproduce-energy-bison 200
  set max-bison-offspring 2
  set max-bison-age 500
  set bison-color [180 90 90]
  set-default-shape bison "buffalo"

 ; set rock-color [216 212 196]
  set rock-color [216 212 196]
  set bison-migrate? false
  set cattle-migrate? false

  set cattle-size 1.4
  set cattle-stride 0.25
  set cattle-reproduce-age 100
  set min-reproduce-energy-cattle 160
  set max-cattle-offspring 2
  set max-cattle-age 400
  set cattle-color [110 110 140]
  set-default-shape cattle "wildebeest"

  set-default-shape rain-lines "line"

  set speed-seasons 4

  set grass-level 0
  set disease-age 20
  set grass-energy 5

  set rain-timer 0

  set max-grasses-energy 200

  set food-bison-eat 4.0
  set food-cattle-eat 4.0

  set rain-band-width 5
  set coefficient-a 0.003

  set grass-color green
  set dirt-color white
  set disease-color [0 0 0 120]

  set-default-shape disease-markers "new-circle"
  set-default-shape embers "fire"
  set-default-shape disruptions "empty"

  set sprout-delay-time 5

  setup-regions 3
  add-starting-grasses

  add-bison region-number-from-name add-bison-to-region
  add-cattle region-number-from-name add-cattle-to-region
  set grazers turtles with  [breed = bison or breed = cattle]

  create-rain-lines 1 [ set color red set shape "rain-line" set size 35 set hidden? true]

   update-bison-fence

  reset-ticks
  set-rain-line-position
  ask patches  [color-water-levels]
end 

to add-starting-grasses
  ask patches [set fertile? false
    if region = 1 [set rain-level 1]
    if region = 2 [set rain-level 1]
    if region = 3 [set rain-level 1]
  ]
  add-grass-in-region 1 %-grassland-southern-region
  add-grass-in-region 2 %-grassland-central-region
  add-grass-in-region 3 %-grassland-northern-region
  ask grasses [visualize-grass]
  add-rocks
end 

to add-grass-in-region [ which-region %-grassland ]
  let region-patches patches with [ region = which-region ]
  let n floor ((%-grassland / 100) * count region-patches)
  ask n-of n region-patches [
    set fertile? true
    sprout 1 [
      set breed grasses
      set color [10 100 10 75]
      set shape "square"
      set plant-energy max-grasses-energy / 2
    ]
  ]
  ask patches [color-water-levels]
end 

to add-more-bison [which-region]
  ifelse any? disruptions with [ disruption-region = which-region ] [
    inform-user-about-max-disruptions which-region
  ]
  [
    if bison-to-add > 0 [
      add-bison which-region
      record-disruption which-region "added more bison"
    ]
  ]
end 

to add-more-cattle [which-region]
  ifelse any? disruptions with [ disruption-region = which-region ] [
    inform-user-about-max-disruptions which-region
  ]
  [
    if cattle-to-add > 0 [
      add-cattle which-region
      record-disruption which-region "added more cattle"
    ]
  ]
end 

to add-bison [which-region]
  let region-patches patches with [ region = which-region ]
  create-bison bison-to-add [                  ;; create the bison, then initialize their variables
    set color bison-color
    set size bison-size
    set energy (20 + (random (50))  )  ;; randomize starting energies
    set current-age 0  + random (max-bison-age) ;; start out bison at different ages
    set max-age max-bison-age
    set #-offspring 0
    move-to one-of region-patches
  ]
end 

to add-cattle [which-region]
  let region-patches patches with [ region = which-region ]
  create-cattle cattle-to-add [                  ;; create the cattle, then initialize their variables
    set color cattle-color
    set size cattle-size
    set energy (20 + (random (50))  )    ;; randomize starting energies
    set current-age 0  + random  (max-cattle-age)  ;; start out bison at different ages
    set max-age max-cattle-age
    set #-offspring 0
    move-to one-of region-patches
  ]
end 

to visualize-rocks
  ask rocks [set hidden? not show-rocky-ground?]
end 


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; runtime procedures ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to go
  if ticks >= 999 and constant-simulation-length? [ stop ]

  ask bison [
    bison-live
    reproduce-bison
  ]

  ask cattle [
    cattle-live
    reproduce-cattle
  ]

  set-rain-line-position
  if rainfall? [set rain-timer rain-timer + 1]

  ask patches [
    color-water-levels
    if visualize-rain-drops? [add-rain-drops]
    grow-grass
  ]
  visualize-rocks
  ask grasses [visualize-grass]
  age-move-rain-drops
  age-and-spread-embers
  update-disease
  update-bison-fence
  tick
end 


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;; disruption procedures ;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to record-disruption [ which-region description ]
  create-disruptions 1 [
    set disruption-region which-region
    set disruption-description description
    set disruption-tick ticks
  ]
  update-plots
end 

to inform-user-about-max-disruptions [which-region]
  ask one-of disruptions with [ disruption-region = which-region ] [
    let region-side item (which-region - 1) ["left" "right"]
    user-message (word
      "You are allowed only one disruption in each ecosystem every time you run the model.\n\n"
      "You have already " disruption-description " in the " region-side " ecosystem.")
  ]
end 


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;; disease procedures ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to update-disease
  ask disease-markers [
    set current-age (current-age + 1)
    if (ticks = 999 and constant-simulation-length?) [
      ask in-link-neighbors [ die ]
      die
    ]
  ]
  infect-other-grazers
end 

to infect-other-grazers

 if not vaccine? [
  ask (turtle-set bison cattle) with [ has-disease? ] [
    ask turtle-set one-of other bison-here with [ not has-disease? ] [
      infect-this-grazer
    ]
    ask turtle-set one-of other cattle-here with [ not has-disease? ] [
      infect-this-grazer
    ]
  ]

  ]
end 

to infect-a-%-of-bison
  ;; procedure for removing a percentage of bison (when button is clicked)
 ; ifelse any? disruptions with [ disruption-region = which-region ] [
 ;   inform-user-about-max-disruptions which-region
 ; ]
 ; [

    let number-bison count bison
    ask n-of floor (number-bison * %-bison-to-infect / 100) bison [infect-this-grazer]
 ;   record-disruption which-region "infected bison"
;  ]
end 

to infect-this-grazer
  hatch-disease-markers 1 [
    set current-age 0
    set size 1.5
    set color disease-color
    create-link-from myself [ tie ]
  ]
end 


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;; fire procedures ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to start-fire

    let current-grass-patches patches with [ fertile? and rain-level <= 1 and pycor = min-pycor and plant-energy >= (.25 * max-grasses-energy)]
    ask current-grass-patches [
      set countdown sprout-delay-time
      set plant-energy 0

      create-ember
    ]
   ; record-disruption which-region "started a wild fire"
end 

to create-ember ;; patch procedure
  sprout 1 [
    set breed embers
    set current-age (sprout-delay-time / 2)
    set color [255 0 0 255]
    set size 1.5
  ]
end 

to age-move-rain-drops


  ask rain-drops [
    set heading 210
    fd 0.05
    set current-age (current-age - 1)
    if current-age <= 0 [ die ]

    let time-to-age-peak abs (current-age - 10)
    let trans-val (150 - round (time-to-age-peak * 15))
   ; if trans-val > 255 or trans-val < 0 [set trans-val 255]
   ; show trans-val
  let color-string []
  set color-string lput 0 color-string
  set color-string lput 0 color-string
  set color-string lput 150 color-string
  set color-string lput trans-val color-string
    set color color-string
  ]
end 

to age-and-spread-embers
  ask embers [
    set plant-energy 0
    set countdown sprout-delay-time
    set current-age (current-age - 1)
    if current-age <= 0 [ die ]
    let my-region region
    ask neighbors4 with [ region = [ region ] of myself and fertile? and grass-energy > (max-grasses-energy / 4) and not any? embers-here ] [
      create-ember
    ]
    let transparency round floor current-age * 255 / sprout-delay-time
    set color lput transparency [255 155 0]
  ]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;; grazers procedures ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to bison-live
  move-bison
  ifelse has-disease?  [set energy (energy - 1.5)][set energy (energy - 1)]
  set current-age (current-age + 1) ;; age by 1.5
  grazers-eat-grass food-bison-eat
  grazer-death
end 

to cattle-live
  move-cattle
  ifelse has-disease?  [set energy (energy - 1.5)][set energy (energy - 1)]
  set current-age (current-age + 1)
  grazers-eat-grass food-cattle-eat
  grazer-death
end 

to move-bison
  head-towards-rains
  rt random 44 - random 44
  let current-region region
  keep-in-region current-region bison-stride
  fd bison-stride
end 

to move-cattle
  head-towards-rains
  rt random 44 - random 44
  let current-region region
  keep-in-region current-region cattle-stride
  fd cattle-stride
end 

to grazers-eat-grass  [food-grazer-eats];; grazers procedurebisonbisonbisonbison
  ;; if there is enough grass to eat at this patch, the grazer eats it
  ;; and then gains energy from it.
    if plant-energy > food-grazer-eats [
      ;; plants lose ten times as much energy as the  gains (trophic level assumption)
      set plant-energy (plant-energy - (food-grazer-eats * 10))
      set energy energy + food-grazer-eats * 1.25 ;;  gain energy by eating
    ]
    ;; if plant-energy is negative, make it positive
    if plant-energy <= food-grazer-eats [ set countdown 5 ]
end 

to grazer-death   ;; a grazer dies when energy dips below zero (starvation), or it gets too old
  if (current-age > max-age) or (energy < 0) [ask out-link-neighbors [ die ] die]
end 

to reproduce-bison  ;; bison procedure
  let number-new-offspring (random (max-bison-offspring + 1)) ;; set number of potential offpsring from 1 to (max-bison-offspring)
  if (energy > ((number-new-offspring + 1) * min-reproduce-energy-bison) and current-age > bison-reproduce-age) [
    set energy (energy - (number-new-offspring * min-reproduce-energy-bison)) ;;lose energy when reproducing --- given to children
    set #-offspring #-offspring + number-new-offspring
    ;; hatch an offspring set it heading off in a a random direction and move it forward a step
    hatch number-new-offspring [
      set energy min-reproduce-energy-bison ;; split remaining half of energy amongst litter
      set current-age 0
      set #-offspring 0
      move-bison
    ]
  ]
end 

to reproduce-cattle  ;; bison procedure
  let number-new-offspring (random (max-cattle-offspring + 1)) ;; set number of potential offpsring from 1 to (max-bison-offspring)
  if (energy > ((number-new-offspring + 1) * min-reproduce-energy-cattle) and current-age > cattle-reproduce-age) [
    set energy (energy - (number-new-offspring * min-reproduce-energy-cattle)) ;;lose energy when reproducing --- given to children
    set #-offspring #-offspring + number-new-offspring
    ;; hatch an offspring set it heading off in a a random direction and move it forward a step
    hatch number-new-offspring [
      set energy min-reproduce-energy-cattle ;; split remaining half of energy amongst litter
      set current-age 0
      set #-offspring 0
      move-cattle
    ]
  ]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;; grass procedures ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; adjust the size of the grass to reflect how much food is in that patch

to grow-grass ;; patch procedure
  set countdown (countdown - 1)
  ;; fertile patches gain 1 energy unit per turn, up to a maximum max-grasses-energy threshold
  if fertile? and countdown <= 0 [
    set plant-energy (plant-energy + grass-growth-rate)
    if plant-energy > max-grasses-energy [
      set plant-energy max-grasses-energy
    ]
  ]
  if not fertile? [
    set plant-energy 0
  ]
  if plant-energy < 0 [
    set plant-energy 0
    set countdown sprout-delay-time
  ]
end 

to visualize-grass
      ifelse plant-energy >= 5
        [ set size (plant-energy / max-grasses-energy) ]
        [ set size ((5 / max-grasses-energy) )]
end 

to add-rocks
  ask patches with [ not fertile?  ]  [
    sprout 1 [
      set breed rocks
      set size 1
      set shape "no-grass"
      set color [10 0 0 25]
      stamp
      die
    ]
  ]
end 

to-report random-rock-color
   let r-min-color 150
   let g-min-color 130
   let b-min-color 130
   let brighten random 20
   let r-offset random 10
   let g-offset random 10
   let b-offset random 10
   let color-list []
   set color-list fput (r-min-color + brighten + r-offset) color-list
   set color-list fput (g-min-color + brighten + g-offset) color-list
   set color-list fput (b-min-color + brighten + b-offset) color-list
   report color-list
end 


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;; water / rain procedures ;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to set-rain-line-position
  ask rain-lines [set xcor lat-sin]
  update-water-levels
end 

to update-water-levels
    let rain-line-pxcor [xcor] of one-of rain-lines
    let low-rain-value 0.5
    let a .25
    ask patches  [
      let distance-from-rain-line abs (pxcor - rain-line-pxcor)
      let rain-band-spread 9

      let distance-to-edge-of-rain ((rain-band-width / 2) + rain-band-spread)
      let xd (distance-from-rain-line - (rain-band-width / 2))
      let rain-at-xd (1 + (3 - (a * xd)))
      if (distance-from-rain-line <= (rain-band-width / 2)) [ set rain-level (4)]
      if (distance-from-rain-line >  (rain-band-width / 2)) and (distance-from-rain-line <=  (distance-to-edge-of-rain)) [ set rain-level rain-at-xd]
      if (distance-from-rain-line >  (distance-to-edge-of-rain)) and (distance-from-rain-line <=  (3 * distance-to-edge-of-rain))
          [ set rain-level (1.4 - (xd - 11) * (1.4 / 22 ))  ]
      if (distance-from-rain-line >  (3 * distance-to-edge-of-rain)) [ set rain-level 0 ]
    ]
end 

to color-water-levels
  let red-channel (255 - (rain-level * (255 - 150) / 4))
  let green-channel (255 - (rain-level * (255 - 175) / 4))
  let blue-channel (255 - (rain-level * (255 - 235) / 4))
  let color-string []
  set color-string lput red-channel color-string
  set color-string lput green-channel color-string
  set color-string lput blue-channel color-string
  set pcolor color-string
end 

to add-rain-drops
  let non-linear-age 20
  if random 100 < (round (rain-level) ^ 1.5)  [
    sprout 1 [set breed rain-drops set shape "drop" set color [0 0 150 70] set heading 0 bk 0.5 fd random-float 1 set heading 90 bk 0.5 fd random-float 1 set current-age 20 set size 0.4]
  ]
end 


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; REGION MANAGEMENT CODE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to setup-regions [ num-regions ]
  ; Store our region definitions globally for faster access:
  set region-boundaries calculate-region-boundaries num-regions
  ; Set the `region` variable for all patches included in regions:
  let region-numbers n-values num-regions [ n -> n + 1 ]
  (foreach region-boundaries region-numbers [ [boundaries region-number] ->
    ask patches with [ pxcor >= first boundaries and pxcor <= last boundaries ] [
      set region region-number
    ]
  ])
  add-dividers
end 

to add-dividers
  set-default-shape dividers "block"
  ask patches with [ region = 0 ] [
    sprout-dividers 1 [
      set color gray + 2
      set size 1.2
    ]
  ]
end 

to-report calculate-region-boundaries [ num-regions ]
  ; The region definitions are built from the region divisions:
  let divisions region-divisions num-regions
  ; Each region definition lists the min-pxcor and max-pxcor of the region.
  ; To get those, we use `map` on two "shifted" copies of the division list,
  ; which allow us to scan through all pairs of dividers
  ; and built our list of definitions from those pairs:
  report (map [ [d1 d2] -> list (d1 + 1) (d2 - 1) ] (but-last divisions) (but-first divisions))
end 

to-report region-divisions [ num-regions ]
  ; This procedure reports a list of pxcor that should be outside every region.
  ; Patches with these pxcor will act as "dividers" between regions.
  report n-values (num-regions + 1) [ n ->
    [ pxcor ] of patch (min-pxcor + (n * ((max-pxcor - min-pxcor) / num-regions))) 0
  ]
end 

to keep-in-region [ which-region grazer-stride] ; turtle procedure
  ; This is the procedure that make sure that turtles don't leave the region they're
  ; supposed to be in. It is your responsibility to call this whenever a turtle moves.

  if [region] of patch-ahead grazer-stride = 0 and which-region != 0 and bison-fences? and
   ((breed = bison and not bison-migrate?) or (breed = cattle and not cattle-migrate?)) [
   let region-min-pxcor first item (which-region - 1) region-boundaries
   let region-max-pxcor last item  (which-region - 1) region-boundaries

    if [pxcor] of patch-ahead grazer-stride = (region-min-pxcor - 1) or [pxcor] of patch-ahead grazer-stride = (region-max-pxcor + 1)
    ; if so, reflect heading around x axis
    [set heading (- heading) ]
    ]
  if pxcor = min-pxcor [set heading 90]
  if pxcor = max-pxcor [set heading -90]
end 

to head-towards-rains
  if ((abs (pxcor - where-rain-band-is) )  > 10.5  and ((cattle-migrate? and breed = cattle) or (bison-migrate? and breed = bison)) ) [
    if (pxcor < where-rain-band-is) [set heading 90]
    if (pxcor > where-rain-band-is) [set heading -90]
]
end 

to update-bison-fence
  ask dividers with [pxcor != min-pxcor and pxcor != max-pxcor] [set hidden? not bison-fences?]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GRAPHING;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to draw-vert-line [ xval ]
  plotxy xval plot-y-min
  plot-pen-down
  plotxy xval plot-y-max
  plot-pen-up
end 

to-report max-plot-y-max
  ;; Reports the highest plot-y-max of the two plots.
  ;; Used for maintaining the same y-scale in both plots.
  let name plot-name ;; save the name of the current plot
  set-current-plot "Population Size vs. Time"
  let ys (list plot-y-max)
  set-current-plot name ;; restore current plot to what it was
  report max ys
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;REPORTERS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to-report has-disease?
  report any? out-link-neighbors
end 

to-report lat-sin

  let rain-band-spread 20
 ; ifelse rainfall?
    set where-rain-band-is  (sin  ( 90  -  (rain-timer * speed-seasons / 10 ) ) * ( max-pxcor - (rain-band-spread / 2)))
   ; [set where-rain-band-is max-pxcor - (rain-band-width / 2)]
  report where-rain-band-is
end 

to-report region-number-from-name [this-region-name]
 let #-region 0

  if this-region-name = "southern region" [set #-region 1]
  if this-region-name = "central region" [set #-region 2]
  if this-region-name = "northern region" [set #-region 3]
  report #-region
end 

to-report grass-growth-rate
  ifelse rain-level > 0 [report   sqrt (rain-level * rain-level )] [report 0]
end 

; Copyright 2015 Uri Wilensky.
; See Info tab for full copyright and license.

There is only one version of this model, created about 1 year ago by Peggy Schultz.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.