Environment-class | R Documentation |
Constructor Function for objects of Reference Class 'Environment'
foragers
a list containing Reference Class objects that inherit from 'Forager' class.
patches
a simple feature data frame with geometries representing patches in the geometry column
bounds
a spatial features collection with one or more polygons defining the region in which any foragers can be created and moved to
initialize(
...,
patches = lapply(rep(2, times = 10), function(x) st_point(runif(x, min = -15, max =
15))) %>% st_sfc %>% data.frame(geom = ., NAME = as.character(1:length(.)),
MAX_VALUE = 10, VALUE = 8, REGEN = 1) %>% st_sf() %>% st_buffer(1) %>%
st_set_crs(32610),
bounds = st_sfc(st_buffer(st_convex_hull(reduce(patches$geometry, c)), 1), crs =
st_crs(patches)),
foragers = createForagers(3, bounds = bounds, speed = 2, quiet = TRUE)
)
Set default values for variables that are not entered manually
plotCurrent()
displays the current location of all foragers and patch geometries
plotPatches()
displays the current patch geometries
plotPaths()
displays the current location and path of all foragers as well as patch geometries
progress()
moves the entire environment forward one timestep by moving all foragers once and processing impact of foraging on patches
## Not run: Environment() newForagers <- list(Forager(), Forager()) #foragers are created by default between -50 and 50 on both the x and y axis newPatches <- lapply(rep(2, times = 20), function(x) st_point(runif(x, min = -50, max = 50))) newPatches <- newPatches %>% st_sfc %>% data.frame(geom = ., NAME = as.character(1:length(.))) newPatches <- newPatches %>% st_sf() %>% st_buffer(1) newBounds <- st_sfc(st_convex_hull(reduce(newPatches$geometry, c)), crs = st_crs(newPatches)) Environment(newForagers, newPatches, newBounds) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.