是否可以在 Netlogo 中创建由补丁颜色定义的边界?
Is it possible in Netlogo to create boundaries defined by patch color?
我试图让我的海龟 "patrol" 进入环境的某个区域,但是当我添加代码来容纳它们时,它们会走到区域的边缘然后停下来,蜱虫也会停止。
相反,如果他们的 "energy" 变量低于 [x]
是否可以允许他们离开领土
对于周长问题,如果我理解你的问题,你可以在你的补丁设置中这样做,以在最大坐标处定义一个周长:
ask patches with [
pxcor = max-pxcor or
pxcor = min-pxcor or
pycor = max-pycor or
pycor = min-pycor ] [
set pcolor red ;; This setup a red perimeter
]
否则你可以选择像这样的精确坐标(16x16 正方形示例):
ask patches with [ pycor >= -16 and pycor >= 16]
[ set pcolor red ]
ask patches with [ pycor <= -16 and pycor <= 16]
[ set pcolor red ]
ask patches with [ pxcor >= -16 and pxcor >= 16]
[ set pcolor red ]
ask patches with [ pxcor <= -16 and pxcor <= 16]
[ set pcolor red ]
然后把它放在你的巡逻步骤中以禁止在红色斑块上行走:
ifelse [pcolor] of patch-ahead 1 = red
[ lt random-float 360 ] ;; See a red patch ahead : turn left randomly
[ fd 1 ] ;; Otherwise, its safe to go foward.
我试图让我的海龟 "patrol" 进入环境的某个区域,但是当我添加代码来容纳它们时,它们会走到区域的边缘然后停下来,蜱虫也会停止。
相反,如果他们的 "energy" 变量低于 [x]
是否可以允许他们离开领土对于周长问题,如果我理解你的问题,你可以在你的补丁设置中这样做,以在最大坐标处定义一个周长:
ask patches with [
pxcor = max-pxcor or
pxcor = min-pxcor or
pycor = max-pycor or
pycor = min-pycor ] [
set pcolor red ;; This setup a red perimeter
]
否则你可以选择像这样的精确坐标(16x16 正方形示例):
ask patches with [ pycor >= -16 and pycor >= 16]
[ set pcolor red ]
ask patches with [ pycor <= -16 and pycor <= 16]
[ set pcolor red ]
ask patches with [ pxcor >= -16 and pxcor >= 16]
[ set pcolor red ]
ask patches with [ pxcor <= -16 and pxcor <= 16]
[ set pcolor red ]
然后把它放在你的巡逻步骤中以禁止在红色斑块上行走:
ifelse [pcolor] of patch-ahead 1 = red
[ lt random-float 360 ] ;; See a red patch ahead : turn left randomly
[ fd 1 ] ;; Otherwise, its safe to go foward.