将代理放在与代理具有相同变量值的补丁上
Put agents on a patch with the same variable value as the agents'
我正在将代理从 .csv 文件加载到扩展名为 csv 的 NetLogo 中。这些代理人将他们居住地的邮政编码作为他们的属性之一。
这些补丁也获得邮政编码的属性,在 GIS 扩展的帮助下从 shapefile 加载。
我想要实现的是将代理直接放入具有匹配邮政编码的补丁之一。
目前有效的是,代理正在行走,直到它们位于正确的补丁中。
这里是简化版:
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
然而,这实际上并不可行,我希望有一个解决方案,将代理直接放在正确的位置。也许用发芽/孵化?
我想过这样的事情(不是工作示例):
ask turtles [
move-to one-of patches with [ location = turtle-location ]
]
但是这段代码给我的错误信息是:
You can't use TURTLE-LOCATION in patch context, because
TURTLE-LOCATION is turtle-only.
试试这个:
ask turtles [
move-to one-of patches with [ location = [turtle-location] of myself ]
]
您需要让 NetLogo 知道要从哪只海龟中获取 turtle-location。
我正在将代理从 .csv 文件加载到扩展名为 csv 的 NetLogo 中。这些代理人将他们居住地的邮政编码作为他们的属性之一。 这些补丁也获得邮政编码的属性,在 GIS 扩展的帮助下从 shapefile 加载。 我想要实现的是将代理直接放入具有匹配邮政编码的补丁之一。
目前有效的是,代理正在行走,直到它们位于正确的补丁中。
这里是简化版:
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
然而,这实际上并不可行,我希望有一个解决方案,将代理直接放在正确的位置。也许用发芽/孵化?
我想过这样的事情(不是工作示例):
ask turtles [
move-to one-of patches with [ location = turtle-location ]
]
但是这段代码给我的错误信息是:
You can't use TURTLE-LOCATION in patch context, because TURTLE-LOCATION is turtle-only.
试试这个:
ask turtles [
move-to one-of patches with [ location = [turtle-location] of myself ]
]
您需要让 NetLogo 知道要从哪只海龟中获取 turtle-location。