This module is a reimplementation in R using the SpaDES and NetLogoR packages of the "Wolf sheep predation" NetLogo model by Wilensky (1997, NetLogo Wolf Sheep Predation model). Please refer to the NetLogo documentation for information on the model.
library(SpaDES.core) library(SpaDES.tools) library(NetLogoR) # Define the parameters wolfSheepParams <- list(.plotInitialTime = NA, .plotInterval = NA, .saveInitialTime = 0, .saveInterval = 1, grassOn = TRUE, grassTGrowth = 30, nSheep = 100, gainFoodSheep = 4, reproSheep = 4, nWolf = 50, gainFoodWolf = 20, reproWolf = 5) # Model init wolfSheepSim <- simInit( times = list(start = 0, end = 500), params = list(WolfSheepPredation = wolfSheepParams), modules = list("WolfSheepPredation"), paths = list(modulePath = "./examples/Wolf-Sheep-Predation") ) # Run the model wolfSheepRun <- spades(wolfSheepSim)
The module events recreate the model procedures from the NetLogo model which are:
grassOn = TRUE
, the sheep loose energy by moving and gain energy by eating grass if there is grass to eat at their location,grassOn = TRUE
, grass grow where grass has been eaten by sheep after a certain time period.The sheep (red) and the wolves (black) positions are plotted on the world. The world is homogeneous if grassOn = FALSE
, or it is heterogeneous if grassOn = TRUE
with green (1) and white (0) patches.
The size of the wolf and sheep populations are recorded in the saving event, as well as the number of green patches in the world if grassOn = TRUE
.
Model parameters must be defined beforehand. Otherwise, no other input data are necessary for this module.
The size of the sheep and wolf populations saved during the simulation, as well as the number of green patches if grassOn = TRUE
, are available at the end of the simulation.
You can access to it with wolfSheepRun$numSheep
, wolfSheepRun$numWolves
and wolfSheepRun$numGreen
.
No anticipated linkages to other modules.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.