HEAD
Report the coordinates of the neighbors patches around the agents.
neighbors(world, agents, nNeighbors, torus = FALSE)
# S4 method for worldNLR,matrix,numeric
neighbors(world, agents, nNeighbors, torus = FALSE)WorldMatrix or worldArray object.
Matrix (ncol = 2) with the first column pxcor and the second
column pycor representing the patches coordinates, or
Integer: 4 or 8. Represents the number of neighbor patches
considered.
Logical to determine if the world is wrapped. Default is
torus = FALSE.
Matrix (ncol = 3) with the first column pxcor
and the second column pycor representing the coordinates of the neighbors
patches around the agents and the third column id representing
the id of the agents in the order provided.
The patch around which the neighbors are identified, or the patch where
the turtle is located on around which the neighbors are identified, is not
returned.
Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University. Evanston, IL.
w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9)
if (requireNamespace("SpaDES.tools", quietly = TRUE)) {
neighbors(world = w1, agents = patch(w1, c(0, 9), c(0, 7)), nNeighbors = 8)
t1 <- createTurtles(n = 3, coords = randomXYcor(w1, n = 3))
neighbors(world = w1, agents = t1, nNeighbors = 4)
}
#> pxcor pycor id
#> [1,] 9 5 1
#> [2,] 8 4 1
#> [3,] 9 3 1
#> [4,] 9 8 2
#> [5,] 8 7 2
#> [6,] 9 6 2
#> [7,] 9 3 3
#> [8,] 8 2 3
#> [9,] 9 1 3
Report the coordinates of the neighbors patches around the agents.
neighbors(world, agents, nNeighbors, torus = FALSE)
# S4 method for worldNLR,matrix,numeric
neighbors(world, agents, nNeighbors, torus = FALSE)WorldMatrix or worldArray object.
Matrix (ncol = 2) with the first column pxcor and the second
column pycor representing the patches coordinates, or
`AgentMatrix` object representing the moving `agents`.Integer: 4 or 8. Represents the number of neighbor patches
considered.
Logical to determine if the world is wrapped. Default is
torus = FALSE.
Matrix (ncol = 3) with the first column pxcor
and the second column pycor representing the coordinates of the neighbors
patches around the agents and the third column id representing
the id of the agents in the order provided.
The patch around which the neighbors are identified, or the patch where
the turtle is located on around which the neighbors are identified, is not
returned.
If `torus = FALSE`, `agents` located on the edges of the
`world` have less than `nNeighbors` patches around them.
If `torus = TRUE`, all `agents` located on the edges of the
`world` have `nNeighbors` patches around them,
which some may be on the other sides of the `world`.Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University. Evanston, IL.
w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9)
if (requireNamespace("SpaDES.tools", quietly = TRUE)) {
neighbors(world = w1, agents = patch(w1, c(0, 9), c(0, 7)), nNeighbors = 8)
t1 <- createTurtles(n = 3, coords = randomXYcor(w1, n = 3))
neighbors(world = w1, agents = t1, nNeighbors = 4)
}
#> pxcor pycor id
#> [1,] 4 8 1
#> [2,] 3 7 1
#> [3,] 5 7 1
#> [4,] 4 6 1
#> [5,] 7 1 2
#> [6,] 6 0 2
#> [7,] 8 0 2
#> [8,] 1 5 3
#> [9,] 0 4 3
#> [10,] 2 4 3
#> [11,] 1 3 3