nl.path <- "C:/Program Files/NetLogo 5.0.3"
NLStart(nl.path)
# NLLoadModel(...)
NLCommand("create-turtles 10")
colors <- NLGetAgentSet(c("who","xcor","ycor","color"),
"turtles with [who < 5]")
str(colors)
# or as a list (slightly faster):
colors.list <- NLGetAgentSet(c("who","xcor","ycor","color"),
"turtles with [who < 5]", as.data.frame=FALSE)
str(colors.list)
# or as a list with one list element for each agent
# (very slow!, not recommended especially for large agentsets)
colors.list2 <- NLGetAgentSet(c("who","xcor","ycor","color"),
"turtles with [who < 5]", as.data.frame=FALSE,
agents.by.row=TRUE)
str(colors.list2)
# getting the ends of links is a little bit more tricky, because they store only the
# reference to the turtles and turtles can not direcly be requested.
# A way to go is:
link.test <- NLGetAgentSet(c("[who] of end1","[who] of end2"),"links")
str(link.test)
Run the code above in your browser using DataLab