我想在我的斑点周围创建一个半月形(黄色),由半径函数(蓝色)创建。
我认为我只能将in-radius value
用于蓝色,in-radius (value + 1)
用于黄色。然后用中心黑色的pycor < pycor
贴片转动所有黄色斑块。
请问,如何将此条件写入我的代码?或者有更简单的解决方案吗?谢谢!
我的代码:
to setup
clear-all
setup-patches
end
to setup-patches
ask patch 0 0 [
set pcolor red
ask patches in-radius 2 [
set pcolor yellow
]
ask patches in-radius 1 [ ; put the blue after yellow to be on the top
set pcolor blue
]
]
ask patches with [pcolor = yellow] [
let ycor_center [pycor] of patch 0 0 ; how to write this condition?
if [pycor] of patch-here > ycor_center [
set pcolor green
]
]
end
答案 0 :(得分:0)
补丁的运行代码不仅位于0 0坐标
to setup
clear-all
setup-patches
end
to setup-patches
ask n-of 5 patches [
set pcolor red
]
ask patches with [pcolor = red] [
let pycor_red pycor ; create variable refering the position of one patch with pcolor = red
ask patches with [pycor >= pycor_red] in-radius 2 [
set pcolor yellow
]
ask patches in-radius 1 [
set pcolor blue
]
]
end
导致: