是否有一个相当简单的程序可以将乌龟聚集在世界的四个边缘?我是新来的,我想让我的乌龟(鲜花)散落在边缘。非常感谢提前!!!
; creating plants (leaves)
to setup-leaves
create-leaves num-plants [ ; number of plants can vary
rand-xy-co ; set random positions for the plants
set shape "flower" ; initialize the plant to color red and size 2
set color red
set size 2
]
end
...
to rand-xy-co
move-to one-of patches with [ pcolor != brown and not any? turtles-here ]
end
...
;set boundary obstacles. These patches tell the robot to stay within identified bounds.
ask patches
[
set pcolor background-colour ; set colour of background
if (pxcor >= max-pxcor - boundary-width) ; boundary width can vary
[ set pcolor brown ]
if (pxcor <= min-pxcor + boundary-width)
[ set pcolor brown ]
if (pycor >= max-pycor - boundary-width)
[ set pcolor brown ]
if (pycor <= min-pycor + boundary-width)
[ set pcolor brown ]
]
答案 0 :(得分:1)
如果你的拓扑没有换行,你可以让edge-patches
成为patches with [count neighbors < 8]
。
如果您的拓扑结构已经封装,您可以将edge-patches
设为patches with [member? pxcor (list max-pxcor min-pxcor) or member? pycor (list max-pycor min-pycor)]
。
如果您想要更粗的边界,您只需更改列表:
to-report edge-patches [#bwidth]
let offsets n-values #bwidth [?]
let xvals (reduce sentence map [(list (min-pxcor + ?) (max-pxcor - ?))] offsets)
let yvals (reduce sentence map [(list (min-pycor + ?) (max-pycor - ?))] offsets)
report patches with [member? pxcor xvals or member? pycor yvals]
end
第h