Create n new turtles on specific patches.

sprout(n, patches, breed, heading, color, turtles)

# S4 method for numeric,matrix
sprout(n, patches, breed, heading, color, turtles)

Arguments

n

Integer. Vector of length 1 or of length the number of patches. Number of new turtles to create on each patch.

patches

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

breed

Character. Vector of "breed" names. Must be of length 1 or of length the number of patches. If missing, breed = "turtle" for all the sprouted turtles.

heading

Numeric. Vector of values between 0 and 360. Must be of length 1 or of length the number of patches. If missing, a random heading is assigned to each sprouted turtle.

color

Character. Vector of color names. Must be of length 1, of length the number of patches or of length sum(n). If missing, colors are assigned using the function rainbow(n)

turtles

AgentMatrix object representing the moving agents.

Value

AgentMatrix including the new sprouted turtles.

Details

nrow(patches) must be equal to 1 or to n.

If turtles is provided, the new turtles are added to the turtles when returned. The who numbers of the sprouted turtles therefore follow the ones from the turtles. All new sprouted turtles are placed at the end of the agentMatrix object. If no turtles is provided, a new agentMatrix is created and the who numbers start at 0.

If turtles is provided and had additional variables created with turtlesOwn(), NA is given for these variables for the new sprouted turtles.

References

Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University. Evanston, IL.

See also

Examples

t1 <- sprout(patches = cbind(pxcor = 2, pycor = 2), n = 3) t2 <- sprout(patches = cbind(pxcor = 3, pycor = 3), n = 3, turtles = t1)