diffuse {NetLogoR} | R Documentation |
Diffuse values in a world
Description
Each patch
gives an equal share of a portion of its value to its neighbor patches
.
Usage
diffuse(world, pVar, share, nNeighbors, torus = FALSE)
## S4 method for signature 'worldMatrix,missing,numeric,numeric'
diffuse(world, share, nNeighbors, torus)
## S4 method for signature 'worldArray,character,numeric,numeric'
diffuse(world, pVar, share, nNeighbors, torus = FALSE)
Arguments
world |
|
pVar |
Character. If the |
share |
Numeric. Value between 0 and 1 representing the portion of
the |
nNeighbors |
Integer: 4 or 8. Represents the number of neighbor |
torus |
Logical to determine if the |
Details
What is given is lost for the patches.
If `torus = TRUE`, all `patches` have `nNeighbors` `patches` around them, which some may be on the other sides of the `world`. If `torus = FALSE`, `patches` located on the edges of the `world` have less than `nNeighbors` `patches` around them. However, each neighbor still gets 1/4 or 1/8 of the shared amount and the diffusing patch keeps the leftover.
Value
WorldMatrix
or worldArray
object with patches
values updated.
Author(s)
Sarah Bauduin
References
Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University. Evanston, IL.
See Also
https://ccl.northwestern.edu/netlogo/docs/dictionary.html#diffuse
<https://ccl.northwestern.edu/netlogo/docs/dictionary.html#diffuse4>
Examples
w1 <- createWorld(
minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4,
data = sample(1:3, size = 25, replace = TRUE)
)
plot(w1)
# Diffuse 50% of each patch value to its 8 neighbors
if (requireNamespace("SpaDES.tools", quietly = TRUE)) {
w2 <- diffuse(world = w1, share = 0.5, nNeighbors = 8)
plot(w2)
}