Evolution and competition for resources

Evolution and competition for resources preview image

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 275 times • Downloaded 15 times • Run 0 times
Download the 'Evolution and competition for 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.)


Model Information and Materials

Model Google Drive Link: https://drive.google.com/open?id=1N9ceIOqQnYKOqj_5di7Vm-d1WImTkhAD

Model GUI overview: https://drive.google.com/open?id=13HzGiZENuLUamqoLXqp9hrBlvFL7j7a-

References and Citation

For this model:

For the NetLogo-Software:

Licence

CC BY-NC-SA 3.0

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. http://creativecommons.org/licenses/by-nc-sa/4.0/

Comments and Questions

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

Click to Run Model

turtles-own [
  harvest-type
  harvest-amount
  harvest
  energy
  myCommons
]

globals [
  pasture1
  pasture2
  turtles1
  turtles2
  commonsResources
  carryingcap
  growthrate
 ]

patches-own [resource]

;;;;;;;;;;;;;;;;;;;;;;
;;;Setup Procedures;;;
;;;;;;;;;;;;;;;;;;;;;;

to setup
  clear-all

  set carryingcap 100
  set growthrate 0.3

  setup-patches
  setup-turtles


  ask turtles [
    if Agents = "Persons" [ set shape "person" set size 1]
    if Agents = "Bacteria" [ set shape "bacteria" set size 1.2]
    if Agents = "Circles" [ set shape "circle" set size 0.8]

    ifelse harvest-type = "sustainable"
      [set color green ]
      [set harvest-type "greedy"
       set color red]
  ]

  reset-ticks
end 

to setup-patches

 ask patches [
    set resource ( 75 + random (carryingcap / 4))
    set pcolor scale-color brown resource  0 (carryingcap + 30)
  ]
end 

to setup-turtles
  ask n-of 50 patches
    [sprout 1
      [set energy Living-costs + 1]]

  ask n-of Sustainables turtles [ set harvest-type "sustainable"]
end 


;;;;;;;;;;;;;;;;;;;;;;;;
;;;Runtime Procedures;;;
;;;;;;;;;;;;;;;;;;;;;;;;

to go
  if count turtles = 0 [stop]
  ask turtles [
    ifelse harvest-type = "sustainable"
      [set harvest-amount Harvest-sustainables ]
      [set harvest-amount Harvest-greedy ]]

  ask turtles [
    if Agents = "Persons" [ set shape "person" set size 1]
    if Agents = "Bacteria" [ set shape "bacteria" set size 1.2]
    if Agents = "Circles" [ set shape "circle" set size 0.8]]

  move
  harvest-patch

  livingcosts

  if Reproduction [reproduce]
  death

  ask patches [
    regrow
    recolor]

  tick
end 

to move ;;turtle procedure

 ask turtles [
    let nextpatch max-one-of (patches in-radius 2 with [not any? turtles-here] ) [resource]
    if nextpatch != nobody
      [ face nextpatch
        move-to nextpatch]

    ]
end 

to harvest-patch
  ask turtles [
   ifelse [resource] of patch-here > harvest-amount
   [set harvest harvest-amount
    ask patch-here [ set resource resource - [harvest-amount] of myself]]
   [set harvest [resource] of patch-here
    ask patch-here [set resource 0]
    ]
    set energy energy + harvest
  ]
end 

to harvest-area ;; from Waring et al., 2017
   ask turtles

  [set commonsResources sum ([resource] of myCommons)  ;; sums all of the resources in my commons
      let commonsList sort-on [resource] myCommons  ;; sort the list by the amount of resource on the patch
      set commonsList reverse commonsList  ;; reverse the sort list so it is largest to smallest

      ifelse commonsResources < harvest-amount  ;; if the total commons are less than what the agent wants to harvest
      [ set harvest (commonsResources); - ( count myCommons * 0.1 ))
        ask myCommons [ set resource 0 ]  ;; take everything from the commons
      ]

      [
        while [harvest < harvest-amount][  ;; while you are still in need
        ;; harvest some resource from the neighborhood
          foreach commonsList [ ?1 ->
            ifelse [resource] of ?1 <= (harvest-amount - harvest)
              [set harvest (harvest + [resource] of ?1 )
               ask ?1 [set resource 0]
              ]

              [ask ?1 [
                set resource (resource - ([harvest-amount] of myself - [harvest] of myself))
              ]
                set harvest harvest-amount
              ]
          ]  ;; end foreach
        ]  ;; end while
        ;;set agentResource floor (agentResource + harvestAmt)
      ] ;; end second part of ifelse commonsResources
  set energy energy + harvest
  ]
end 

to livingcosts
  ask turtles [set energy energy - Living-costs]
end 

to reproduce
 ask turtles
  [ let neighborhood  (patch-set neighbors with [not any? turtles-on self ])
      if (any? neighborhood)  and random-float 1 < ( 0.001 * energy );;/ 100)
        [hatch 1 [
        mutate
         set energy ([energy] of myself / 2)
         move-to one-of neighborhood

          ]
        set energy (energy / 2)
        ]
     ]
end 

to mutate  ;; turtle procedure
    if random-float 100 < Mutation-rate
    [ifelse harvest-type = "sustainable"
      [set harvest-type "greedy"]
      [set harvest-type "sustainable"]
    ]
   update-color
end 

to update-color
   ifelse harvest-type = "sustainable"
      [ set color green ]
      [ set color red ]
end 

to death
  ask turtles
  [if energy <= 0 [die]
     if random-float 100 < Death-rate [ die ]]
end 

to regrow ;; patch
  ifelse resource > 0
  [set resource precision (resource + ((growthrate * resource) * (1 - (resource / carryingcap )))) 3]
  [ set resource 0.1]
end 

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

;;; Farmers1 variables

to-report average-energy-greedys
  report sum [energy] of turtles with [harvest-type = "greedy"] / count turtles with [harvest-type = "greedy"]
end 

to-report average-energy-sustainables
  report sum [energy] of turtles with [harvest-type = "sustainable"] / count turtles with [harvest-type = "sustainable"]
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 competition for resources.png preview Preview for 'Evolution and competition for resources' over 3 years ago, by Susan Hanisch Download

This model does not have any ancestors.

This model does not have any descendants.