Learn R Programming

NetLogoR (version 0.3.9)

turtlesAt: Turtles at

Description

Report the individuals among turtles that are located on the patches at (dx, dy) distances of the agents.

Usage

turtlesAt(world, turtles, agents, dx, dy, breed, torus = FALSE)

# S4 method for worldNLR,agentMatrix,matrix,numeric,numeric,missing turtlesAt(world, turtles, agents, dx, dy, torus)

# S4 method for worldNLR,agentMatrix,matrix,numeric,numeric,character turtlesAt(world, turtles, agents, dx, dy, breed, torus = FALSE)

Arguments

world

WorldMatrix or worldArray object.

turtles

AgentMatrix object representing the moving agents.

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.

breed

Characters. Vector of breed names for the selected turtles. If missing, there is no distinction based upon breed.

torus

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

Value

AgentMatrix representing the individuals among turtles of any of the given breed, if specified, which are located on the patches at (dx, dy) distances of the agents.

Details

If the patch at distance (dx, dy) of an agent is outside of the world's extent and torus = FALSE, no turtle is returned; if torus = TRUE, the turtle located on the patch whose coordinates are defined from the wrapped world is 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#turtles-at

https://ccl.northwestern.edu/netlogo/docs/dictionary.html#at-points

Examples

Run this code
# NOT RUN {
w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9)
t1 <- createTurtles(n = 10, coords = cbind(xcor = 0:9, ycor = 0:9),
                    breed = c(rep("sheep", 5), rep("wolf", 5)))
t2 <- turtlesAt(world = w1, turtles = t1, agents = turtle(t1, who = 0),
                dx = 1, dy = 1)
t3 <- turtlesAt(world = w1, turtles = t1,
                agents = patch(w1, c(3,4,5), c(3,4,5)), dx = 1, dy = 1,
                breed = "sheep")


# }

Run the code above in your browser using DataLab