patchAt: 'Patches' at

patchAtR Documentation

Patches at

Description

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

Usage

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

## S4 method for signature '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.

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.

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.

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#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)



NetLogoR documentation built on Aug. 17, 2022, 9:06 a.m.