我下载了修改后的随机集群代码,用于使用 NetLogo 建模共享中修改后的随机集群方法的 Millington 版本生成中性景观模型。当我单击“generate-landscape”按钮时,代码中的“fill-landscape”过程会导致“Nothing named ? has been defined”错误。
当我创建附加的界面图像并尝试运行下面的相邻代码时。该问题似乎与“发生次数”报告功能中的问号有关。reduce 函数未按预期工作。有解决办法吗?查看界面,然后代码如下:
ifelse ( any? neighbours with [ cluster != nobody ] ) ;; check if there are any assigned patches in neighbourhood
[
let covers []
ask neighbours with [ cluster != nobody ]
[
set covers fput cover covers ;;ask neighbours to add their covers to the list
]
let unique-covers remove-duplicates covers ;;create a list of unique covers
let max-cover-count -1 ;the number of neighbours with the …Run Code Online (Sandbox Code Playgroud) 假设您有以下代码(由 @Nicolas-Payette 提供),您将如何在 netlog 中使用 dbscan 查找平均簇间距离:
extensions [ dbscan ]
to setup
clear-all
ask patches [ set pcolor white ]
create-turtles 1000 [
set color black
set label-color blue
setxy random-xcor random-ycor
]
ask n-of 5 turtles [
ask turtles in-radius 3 [
set color one-of [red grey]
]
]
end
to find-clusters
let red-grey-turtles turtles with [ member? color [red grey] ]
let clusters dbscan:cluster-by-location red-grey-turtles 3 3
(foreach clusters range length clusters [ [c i] ->
foreach …Run Code Online (Sandbox Code Playgroud) netlogo ×2