Test Upload from NetLogo

Test Upload from NetLogo preview image

1 collaborator

Default-person David Weintrop (Author)

Tags

(This model has yet to be categorized with any tags)
Model group MAM-2013 | Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.2.0 • Viewed 244 times • Downloaded 8 times • Run 0 times
Download the 'Test Upload from NetLogo' modelDownload this modelEmbed this model

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


ACKNOWLEDGEMENT

This model is from Chapter Four of the book "Introduction to Agent-Based Modeling: Modeling Natural, Social and Engineered Complex Systems with NetLogo", by Uri Wilensky & William Rand.

Wilensky, U. & Rand, W. (2015). Introduction to Agent-Based Modeling: Modeling Natural, Social and Engineered Complex Systems with NetLogo. Cambridge, MA. MIT Press.

This model is in the IABM Textbook folder of the NetLogo models library. The model, as well as any updates to the model, can also be found on the textbook website: http://intro-to-abm.com.

WHAT IS IT?

This is the fifth model in a set of models that build towards a predator prey model of population dynamics. This fifth model adds wolves and completes the predator prey model.

It extends the model Wolf Sheep Simple 4.

HOW IT WORKS

The model creates a population of sheep that wander around the landscape. For each step the sheep take it costs them some energy and if there energy gets too low they die. However, the sheep can eat grass in the environment to regain energy and the grass regrows over time. If the energy of the sheep gets above a certain level then they can reproduce.

In this fifth model, there are also wolves. Wolves have the same behaviors as sheep except for eating; rather than grass, they eat sheep.

HOW TO USE IT

Set the NUMBER-OF-SHEEP slider and press SETUP to create the initial population. You can also change the MOVEMENT-COST slider to affect the energy cost of movement for the sheep. The GRASS-REGROWTH-RATE slider affects how fast the grass grows back, while the ENERGY-GAIN-FROM-GRASS slider affects how much energy the sheep can gain from eating the grass, and the ENERGY-GAIN-FROM-SHEEP slider affects how much energy the wolves gain from eating sheep.

After this, press the GO button to make the sheep and wolves move around the landscape, and interact.

THINGS TO NOTICE

How does the number of sheep affect the population levels? How does the number of wolves affect the population levels?

Is there a spatial relationship between where the sheep do well and where the wolves do well?

How does the presence of wolves affect the system?

THINGS TO TRY

Change the NUMBER-OF-WOLVES, while leaving the NUMBER-OF-SHEEP constant, how does this affect the model results?

How does the ENERGY-GAIN-FROM-SHEEP affect the model results?

Try to play around with ENERGY-GAIN-FROM-GRASS and GRASS-REGROWTH-RATE. Does keeping the influx of energy constant but with different slider valeus (e.g. ENERGY-GAIN-FROM-GRASS as 1 and GRASS-REGROWTH-RATE as 2, and vice versa) give the same or different results? Why might that be?

RELATED MODELS

The Wolf Sheep Predation Model in the Biology section of the NetLogo models library.

HOW TO CITE

This model is part of the textbook, "Introduction to Agent-Based Modeling: Modeling Natural, Social and Engineered Complex Systems with NetLogo."

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

For the model itself:

Please cite the NetLogo software as:

Please cite the textbook as:

  • Wilensky, U. & Rand, W. (2015). Introduction to Agent-Based Modeling: Modeling Natural, Social and Engineered Complex Systems with NetLogo. Cambridge, MA. MIT Press.

COPYRIGHT AND LICENSE

Copyright 2007 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 http://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

breed [sheep a-sheep]
breed [wolves wolf]

turtles-own [ energy ]  ;; agents own energy

patches-own [ grass ]  ;; patches have grass

;; this procedures sets up the model

to setup
  clear-all
  ask patches [  
    ;; give grass to the patches, color it shades of green
    set grass random-float 10.0
    recolor-grass ;; change the world green
  ]
  create-sheep number-of-sheep [  ;; create the initial sheep
    setxy random-xcor random-ycor
    set color white
    set shape "sheep"
    set energy 100  ;; set the initial energy to 100
  ]
  create-wolves number-of-wolves [  ;; create the initial wolves
    setxy random-xcor random-ycor
    set color brown
    set shape "wolf"
    set size 2 ;; increase their size so they are a little easier to see
    set energy 100  ;; set the initial energy to 100
  ]
  reset-ticks
end 

;; make the model run

to go
  if not any? turtles [  ;; now check for any turtles, that is both wolves and sheep
    stop
  ]
  ask turtles [  ;; ask both wolves and sheep
    wiggle  ;; first turn a little bit
    move  ;; then step forward
    check-if-dead  ;; check to see if agent should die
    eat            ;; sheep eat grass, wolves eat sheep
    reproduce
  ]
  regrow-grass ;; regrow the grass
  tick         
  my-update-plots  ;; plot the population counts
end 

;; wolf procedure, wolves eat sheep

to eat-sheep
  if any? sheep-here [  ;; if there are sheep here then eat one
    let target one-of sheep-here
    ask target [
      die
    ]
    ;; increase the energy by the parameter setting
    set energy energy + energy-gain-from-sheep
  ]
end 

;; turtle procedure (both wolves and sheep); check to see if this turtle has enough energy to reproduce

to reproduce
  if energy > 200 [
    set energy energy - 100  ;; reproduction transfers energy
    hatch 1 [ set energy 100 ] ;; to the new agent
  ]
end 

;; recolor the grass to indicate how much has been eaten

to recolor-grass
;;  set pcolor scale-color green grass 0 20 
set pcolor scale-color green (10 - grass) 20 -10 
end 

;; regrow the grass

to regrow-grass
  ask patches [
    set grass grass + grass-regrowth-rate
    if grass > 10.0 [
      set grass 10.0
    ]
    recolor-grass
  ]
end 

to eat
  ifelse breed = sheep 
  [eat-grass]
  [eat-sheep]
end 

;; sheep procedure, sheep eat grass

to eat-grass
  ;; check to make sure there is grass here
  if ( grass >= energy-gain-from-grass ) [    
    ;; increment the sheep's energy
    set energy energy + energy-gain-from-grass
    ;; decrement the grass
    set grass grass - energy-gain-from-grass
    recolor-grass
  ]
end 

;; turtle procedure, both wolves and sheep

to check-if-dead
 if energy < 0 [
    die
  ]
end 

;; update the plots

to my-update-plots
  set-current-plot-pen "sheep"
  plot count sheep
  
  set-current-plot-pen "wolves"
  plot count wolves * 10 ;; scaling factor so plot looks nice
  
  set-current-plot-pen "grass"
  plot sum [grass] of patches / 50 ;; scaling factor so plot looks nice
end 

;; turtle procedure, the agent changes its heading

to wiggle
  ;; turn right then left, so the average is straight ahead
  rt random 90
  lt random 90
end 

;; turtle procedure, the agent moves which costs it energy

to move
  forward 1  
  set energy energy - movement-cost ;; reduce the energy by the cost of movement
end 


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

There is only one version of this model, created almost 9 years ago by David Weintrop.

Attached files

File Type Description Last updated
Test Upload from NetLogo.png preview Preview for 'Test Upload from NetLogo' almost 9 years ago, by David Weintrop Download

This model does not have any ancestors.

This model does not have any descendants.