Netlogo 在斑块簇的边缘放置海龟
我正在寻找一种快速将海龟放置在斑块簇边缘的方法。我尝试了此代码,但发现当我增加学习区域的大小时,速度有点慢:Netlogo 在斑块簇的边缘放置海龟,netlogo,Netlogo,我正在寻找一种快速将海龟放置在斑块簇边缘的方法。我尝试了此代码,但发现当我增加学习区域的大小时,速度有点慢: to draw-edges [ID-cluster] ask patches with [cluster != ID-cluster] [ ask neighbors with [cluster = ID-cluster] [ if not any? turtles-here [ sprout 1 [ set shape "x" ] ] ] ] end
to draw-edges [ID-cluster]
ask patches with [cluster != ID-cluster] [
ask neighbors with [cluster = ID-cluster] [
if not any? turtles-here [
sprout 1 [
set shape "x" ] ] ] ]
end
提前感谢您的帮助。您当前正在请求群集中外部的所有人检查群集中的邻居。让集群中的补丁程序检查它们是否位于外部补丁程序的旁边应该会更快:
to draw-edges [ ID-cluster ]
ask patches with [
cluster = ID-cluster and
any? neighbors with [cluster != ID-cluster] and
not any? turtles-here
] [
sprout 1
set shape "x"
]
end