Netlogo 每片地的海龟间隔 创建墙的步骤 使用[(pycor>((宽度))和pycor((宽度))和pycor((lengthrec))和pxcor((lengthrec))和pxcor(间隙*(-1))和pxcor
如上所述,创建一个框,如下所示: 因此,每个地块有两个海龟/墙。我希望将其增加到三个,或者如果可能的话,编写一个代码,我可以将每个补丁的海龟/墙的数量作为变量进行变量Netlogo 每片地的海龟间隔 创建墙的步骤 使用[(pycor>((宽度))和pycor((宽度))和pycor((lengthrec))和pxcor((lengthrec))和pxcor(间隙*(-1))和pxcor,netlogo,agent,Netlogo,Agent,如上所述,创建一个框,如下所示: 因此,每个地块有两个海龟/墙。我希望将其增加到三个,或者如果可能的话,编写一个代码,我可以将每个补丁的海龟/墙的数量作为变量进行变量 谢谢。如果我正确理解您正在做的事情,那么将sprout walls 1中的1更改为变量就可以了。 设定一个3 长墙[东西] A也可以是输入或滑块变量 将它们随机分布在整个补丁中 把这个放进去发芽 to create-wall set breadth-patches patches with[(pycor > (-(
谢谢。如果我正确理解您正在做的事情,那么将sprout walls 1中的1更改为变量就可以了。 设定一个3 长墙[东西] A也可以是输入或滑块变量 将它们随机分布在整个补丁中 把这个放进去发芽
to create-wall
set breadth-patches patches with[(pycor > (-(breadth)) and pycor < breadth and pxcor = lengthrec) or(pycor > (-(breadth)) and pycor < breadth and pxcor = (-(lengthrec))) ]
set length-patches patches with[(pxcor > (-(lengthrec)) and pxcor < lengthrec and pycor = (-(breadth - 1))) or (pxcor > (-(lengthrec)) and pxcor < lengthrec and pycor = (breadth - 1))]
set gap-patches patches with [pxcor > (gap * (-1)) and pxcor < gap and pycor =(breadth - 1)]
set length-patches length-patches with [not member? self gap-patches]
ask breadth-patches[
sprout-walls 1[set color 2
set size 0.5 set heading 180 fd 0.25
if-else(pxcor < 0)[set heading 90][set heading 270] fd 0.25]
sprout-walls 1[set color 2
set size 0.5 set heading 360 fd 0.25
if-else(pxcor < 0)[set heading 90][set heading 270] fd 0.25]
]
ask length-patches[
sprout-walls 1[
set color 2
set size 0.5 set heading 90 fd 0.25
if-else(pycor < 0)
[
set heading 180]
[
set heading 0]
fd 0.25
]
sprout-walls 1[
set color 2
set size 0.5
set heading 270
fd 0.25
if-else(pycor < 0)
[
set heading 180]
[
set heading 0] fd 0.25
]
]
end
为了将它们排列起来,我将把它写成一个过程
Setxy (xcor + random-float 1 - .5) (ycor + random-float 1 - .5)
数字是你想要的海龟数量方向是水平的,0是垂直的,90是垂直的,这会造成海龟互相重叠。我看不清楚。你想让他们排成一行吗?或者随机分布在整个补丁中?我希望它们“排成一行”。设置标题0 bk.5 fd(这里计数海龟/a);;我担心最后一只乌龟就在边缘,所以/(a+1)可能更好。我似乎不明白你的解决方案。随机浮动的用途是什么。
to Make-line [number orientation]
Let c 0 ;; this is a counter
Crt 5
[
;; your create code goes here
Let c c + 1
Set heading orientation bk .5 fd ( c / ( number + 1)
]
End