我想在森林周围划出30米的边缘(见下图)。这是我的代码(1补丁= 10米)
to create-forest-edges
let forest-edge 30
set patch-side 10
ask patches with [pcolor != 53] [
ask neighbors with [pcolor = 53] [
set pcolor green ] ]
repeat (forest-edge / patch-side) - 1 [
ask patches with [pcolor = green] [
ask neighbors with [pcolor = 53] [
set pcolor green ] ] ]
end
位于世界极端的一些补丁没有绿色边缘。我不知道为什么? 非常感谢您的帮助。
答案 0 :(得分:2)
相反如何:
ask patches with [pcolor = 53] [
ask patches in-radius 3 with [pcolor != 53] [
set pcolor green
]
]
答案 1 :(得分:1)
森林必须距离边缘至少3个补丁才能工作。因此,在您的林生成代码中,只需确保边缘附近没有任何补丁被着色为森林。