我的模型我有几个版本的世界应该是什么样子。我将其实现为“选择器”,包括选择: “single_tree” “集群”。我的世界是501 * 501补丁。
当我运行我的两个版本的setup
时,在我按下工具 - >之前不会创建它们。 “停”。
我真的不明白为什么,因为在我的工作模式上这很好用。当我用基本参数运行这个“世界变化”时 - 只需用[set pcolor ...]。
请问我的模特中有什么不好或我做错了什么?
这是工作示例 - 工作正常:
to setup-patches ; define patchy landscape
ask patches [
; Single tree
; -------------------------
if world = "single_tree" [
set pcolor green
]
; Clustered trees
; -------------------------
if world = "clustered" [
set pcolor red
]
end
这里有一些更复杂的代码,但我认为没有任何理由花费这么长时间来进行调度..
to setup-patches ; define patchy landscape
ask patches [
; Single tree
; -------------------------
if world = "single_tree" [
ask patches with [pxcor mod 50 = 0 and pycor mod 50 = 0] [
set pcolor red
]
]
; Clustered trees
; -------------------------
if world = "clustered" [
ask patch 0 0 [
ask patches in-radius (2.99 * Grid) with [pxcor mod Grid = 0 and pycor mod Grid = 0] [
set pcolor red
]
]
; ; determine cluster size
ask patches with [pcolor = red] [
ask patches in-radius radius [
set pcolor yellow
]
]
]
end
我真的很感激任何建议,非常感谢你!
答案 0 :(得分:1)
我的问题是我用了很多次“ask patches
”到“ask patches
”来做某事......
固定代码在此处 - ask patches
每if
个语句只有一次:
to setup-patches
if world = "single_tree" [
ask patches with [pxcor mod 50 = 0 and pycor mod 50 = 0] [
set pcolor red
]
]
if world = "clustered" [
ask patch 0 0 [ ask patches in-radius (2.99 * Grid) with [pxcor mod Grid = 0 and pycor mod Grid = 0] [
set pcolor red
]
]
ask patches with [pcolor = red] [
ask patches in-radius 5 [
set pcolor yellow
]
]
]
end