在世界边缘的netlogo中随机创建海龟

在世界边缘的netlogo中随机创建海龟,netlogo,Netlogo,是否有一个相当简单的程序可以将海龟聚集在世界的四个边缘?我是新手,我想让我的海龟(花)散落在边缘。提前谢谢你 ; 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" ; in

是否有一个相当简单的程序可以将海龟聚集在世界的四个边缘?我是新手,我想让我的海龟(花)散落在边缘。提前谢谢你

; 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 ]
  ]

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 ]
  ]
;设置边界障碍。这些补丁告诉机器人保持在确定的边界内。
询问补丁
[
设置pcolor背景颜色;设置背景颜色
如果(pxcor>=最大pxcor-边界宽度),则边界宽度可以变化
[设置颜色为棕色]
如果(pxcor=最大pycor-边界宽度)
[设置颜色为棕色]

如果(pycor如果您的拓扑没有包裹,您可以让您的
边面片
成为具有[count neighbories<8]
面片

如果拓扑进行换行,则可以使用[member?pxcor(list max pxcor min pxcor)或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

hth.

抱歉,我想我在我的帖子中把你弄糊涂了……我是netlogo的新手,但我没有解释清楚。我希望能够更改rand xy co,以便它生成边缘周围的叶子。我的拓扑结构没有包裹…我理解边缘补丁的方式是边界?还是没有?[抱歉,有点迷失]如果我了解您想要什么,您可以使用[这里没有海龟]
移动到其中一个边缘修补程序3,假设边界宽度为3。(但是如果您要多次这样做,您应该将边缘修补程序存储在全局中,这样您就不会重复重新创建它们。)另外,不要忽略使用
sprout
的可能性。例如,如果您的补丁当前为空,
ask n-of-num plants edge patches 3[sprout leaves 1]
将创建
num plants
叶子,每个叶子都在自己的补丁上。