Report the coordinates of the patches at (dx, dy) distances of the agents.

patchAt(world, agents, dx, dy, torus = FALSE)

# S4 method for worldNLR,matrix,numeric,numeric
patchAt(world, agents, dx, dy,
  torus = FALSE)

Arguments

world

WorldMatrix or worldArray object.

agents

Matrix (ncol = 2) with the first column "pxcor" and the second column "pycor" representing the patches coordinates, or

AgentMatrix object representing the moving agents.

dx

Numeric. Vector of distances to the east (right) from the agents. If dx is negative, the distance to the west (left) is computed. dx must be of length 1 or of the same length as number of patches or turtles in agents.

dy

Numeric. Vector of distances to the north (up) from the agents. If dy is negative, the distance to the south is computed (down). dy must be of length 1 or of the same length as number of patches or turtles in agents.

torus

Logical to determine if the world is wrapped. Default is torus = FALSE.

Value

Matrix (ncol = 2) with the first column "pxcor" and the second column "pycor" representing the coordinates of the patches at (dx, dy) distances of the agents. The order of the patches follows the order of the agents.

Details

If the patch at distance (dx, dy) of an agent is outside of the world's extent and torus = FALSE, NA are returned for the patch coordinates; if torus = TRUE, the patch coordinates from a wrapped world are returned.

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#patch-at https://ccl.northwestern.edu/netlogo/docs/dictionary.html#at-points

Examples

w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9) patchCorner <- patchAt(world = w1, agents = patch(w1, 0, 0), dx = 1, dy = 1) t1 <- createTurtles(n = 1, coords = cbind(xcor = 0, ycor = 0)) patchCorner <- patchAt(world = w1, agents = t1, dx = 1, dy = 1)