【发布时间】:2018-06-11 09:27:09
【问题描述】:
在土地利用模型中,我想计算绿色和红色簇的大小,如下图所示:
使用的代码与模型库中的“补丁簇示例”中的代码非常相似,唯一的区别是它只计算红色和绿色补丁。但是当我运行它时,Netlogo 状态“堆栈溢出(递归太深)错误,而观察者运行由过程 FIND-CLUSTERS 调用的 ASK”。这是查找集群的过程:
to find-clusters
loop [
;; pick a random patch that isn't in a cluster yet
let seed one-of patches with [cluster = nobody and pcolor = 64 or
pcolor = 14]
;; if we can't find one, then we're done!
if seed = nobody
[ show-clusters
stop ]
;; otherwise, make the patch the "leader" of a new cluster
;; by assigning itself to its own cluster, then call
;; grow-cluster to find the rest of the cluster
ask seed
[ set cluster self
grow-cluster ]
]
display
end
以及增长集群过程:
to grow-cluster ;; patch procedure
ask neighbors4 with [(cluster = nobody) and
(pcolor = [pcolor] of myself)]
[ set cluster [cluster] of myself
grow-cluster ]
end
该消息是什么意思,我该如何解决?谢谢。
【问题讨论】:
标签: netlogo