Evolution and patchy resources

Evolution and patchy resources preview image

This model is seeking new collaborators — would you please help?

1 collaborator

Default-person Susan Hanisch (Author)

Tags

evolution 

Tagged by Susan Hanisch over 3 years ago

Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.1.1 • Viewed 239 times • Downloaded 15 times • Run 0 times
Download the 'Evolution and patchy resources' modelDownload this modelEmbed this model

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

breed [plants plant]
breed [foragers forager]

foragers-own
[eattype
 energy
 mypatch]

patches-own [
  seedpatch?
  seedpatchnum
  foodpatch?
  foodpatchnum
  assortindex
  resource]

globals
[patch-width
 gap
 foodpatchlist
 growth-rate
 carryingcap
 ;;maxpop
 costchild
]

to setup
  clear-all

  set patch-width Size-Resource-Areas
  set gap Distance-Resource-Areas
  set growth-rate 0.2
  set carryingcap 10
  ;;set maxpop 400

  setup-plants
  setup-frgs
  set costchild 10

  reset-ticks
end 

to setup-plants
 foreach [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13]
  [ x  ->
      foreach [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13] [ y  ->
  ask patches with [ pxcor = ( gap / 2 ) + (x * ( gap + (patch-width )))  and pycor =  ( gap / 2 ) + (y * (gap + (patch-width))) ]
  [set seedpatch? true
        sprout-plants 1 [set hidden? true]
        set seedpatchnum [who] of plants-here
   ]
  ]
  ]

  ask patches with [seedpatch? = true]
  [ let localpatch (patch-set self patches in-radius patch-width)
    ask localpatch
     [ set resource carryingcap

       if resource = 0 [set resource 0.1]
        set pcolor scale-color brown resource 0 (carryingcap + 10)
        set foodpatch? true
        set foodpatchnum [seedpatchnum] of localpatch with [seedpatch? = true]
    ]
  ]

  set foodpatchlist (  [who] of plants )
end 

to setup-frgs
  ask n-of (Number-Agents * Percent-Sustainables / 100) patches with [foodpatch? = true]
  [sprout-foragers 1
    [
      set eattype "low"

    set color green
    set mypatch [foodpatchnum] of patch-here ]
  ]

   ask n-of (Number-Agents * ( 100 - Percent-Sustainables) / 100) patches with [foodpatch? = true]
  [sprout-foragers 1
    [
      set eattype "high"

      set color red
      set mypatch [foodpatchnum] of patch-here
    ]
  ]

  ask foragers [
    if Agents = "People" [ set shape "person"]
    if Agents = "Bacteria" [ set shape "bacteria" ]
    if Agents = "Cows" [ set shape "cow"]
    if Agents = "Cells" [ set shape "cell"]
  set size 2
  set energy Living-costs]
end 

to go

   ask foragers [
    if Agents = "People" [ set shape "person"]
    if Agents = "Bacteria" [ set shape "bacteria" ]
    if Agents = "Cows" [ set shape "cow"]
    if Agents = "Cells" [ set shape "cell"]]

  move
  eat
  if Evolution? [reproduce]
  expend-energy
  if Evolution? [death]

  ask patches with [foodpatch? = true]
  [regrow
    recolor]

  tick
end 

to move
  ask foragers
  [let local ( patch-set patch-here ( patches in-radius 2 with [not any? foragers-here] ))
   if local != nobody
    [let local-max  ( max-one-of local [resource]  )
    ifelse local-max != nobody and [resource] of local-max >= Living-costs
      [face local-max
        move-to local-max
        set mypatch [foodpatchnum] of patch-here
      ]
      [if any? ( patches in-radius 2 with [not any? foragers-here] )
        [move-to one-of ( patches in-radius 2 with [not any? foragers-here] )]]
  ]
  ]
end 

to eat
  ask foragers
  [ifelse eattype = "low"
    [ set  energy energy + ([resource] of patch-here * 0.5)
      ask patch-here [set resource resource / 2]]
    [ set  energy energy + ([resource] of patch-here * 0.99)
      ask patch-here [set resource resource - (0.99 * resource) ]]
  ]
end 

to reproduce
 ask foragers
  [ let birthrate 0.0005 * energy
  if energy > costchild and random-float 1 < birthrate [
     let destination one-of neighbors with [not any? turtles-here]
     if destination != nobody [
        hatch 1 [
          move-to destination
          mutate
          set energy costchild ]
        set energy (energy - costchild)
       ]
      ]
      ]
end 

to mutate
  if random-float 1 < Mutation-rate
  [ifelse eattype = "low"
    [set eattype "high"]
    [set eattype "low"]
    update-color
  ]
end 

to expend-energy
  ask foragers [set energy energy - Living-costs]
end 

to death
  ask foragers
  [if energy <= 0 [die]
  ]
end 

to regrow
  ifelse resource >= 0.1
  [set resource precision (resource + ((growth-rate * resource) * (1 - (resource / carryingcap )))) 3]
  [set resource 0.1]
end 

to recolor ;; patch
  set pcolor scale-color brown resource 0 (carryingcap + 10)
end 

to update-color
  ifelse eattype = "low"
    [set color green]
    [set color red]
end 

to calcassort
  foreach (foodpatchlist) [ x ->
    let foodpatch patches with [foodpatchnum = x]
    let lowfrgs count foragers with [eattype = "low" and mypatch = x]
    let frgs count foragers with [ mypatch = x]
    ask patches with [seedpatch? = true and seedpatchnum = x]
      [ set assortindex (lowfrgs / frgs) ]
    ]
end 

;;;;;;;;;;;;;;;;;;reporters;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to-report avenhigh
  report sum [energy] of foragers with [eattype = "high"] / count foragers with [eattype = "high"]
end 

to-report avenlow
  report sum [energy] of foragers with [eattype = "low"] / count foragers with [eattype = "low"]
end 

to-report gensim-pop
  report ( count patches with [seedpatch? = true] - 1) / (count foragers - 1)
end 

to-report avassort
  report sum [assortindex] of patches with [seedpatch? = true] / count patches with [seedpatch? = true]
end 

There is only one version of this model, created over 3 years ago by Susan Hanisch.

Attached files

File Type Description Last updated
Evolution and patchy resources.png preview Preview for 'Evolution and patchy resources' over 3 years ago, by Susan Hanisch Download

This model does not have any ancestors.

This model does not have any descendants.