I am loading my agents from a .csv file into NetLogo with the csv extension. These agents have as one of their attributes the ZIP-code from where they live. The patches get as attributes the ZIP-code as well, loaded from a shapefile with the help of the GIS-extension. What I want to achieve is that the agents are put directly into one of the patches with the matching ZIP-code.
What is working at the moment is, that the agents are walking until they are in the correct patch.
Here, a simplified version:
turtles-own [ turtle-location ]
patches-own [ location ]
to setup
ca
crt 10 [
set turtle-location random 10
]
ask patches [
set location random 10
]
end
to go
ask turtles [
location-turtles
]
end
to location-turtles
if (location != turtle-location)
[ fd 2 ]
end
However, this is not really feasible and I am hoping for a solution where the agents are put directly on their correct location. Maybe with sprout/ hatch?
I thought about something like this (not working example):
ask turtles [
move-to one-of patches with [ location = turtle-location ]
]
But this piece of code gives me the error message:
You can't use TURTLE-LOCATION in patch context, because TURTLE-LOCATION is turtle-only.
Try this:
ask turtles [
move-to one-of patches with [ location = [turtle-location] of myself ]
]
You need to let NetLogo know which turtle to get the turtle-location from.