如何手动调整netlogo界面的环绕拓扑?

How to manually adjust wrapping topology of netlogo interface?

Netlogo 仅提供四种拓扑选项,用于指示海龟和补丁在到达 netlogo 世界或界面的任何给定边缘时执行的操作,即框、圆环、水平环绕和垂直环绕...有没有办法调整这些选项以便只包裹一个边缘?或者例如包裹了三个边缘?

Nigus- 我确实记得,我永远不会忘记一只柯基犬!无论如何,正如 Jen 所提到的,没有内置的,但你可以将它构建到你的乌龟移动规则中。例如,使用此设置:

to setup
  ca
  crt 10 [ pd ]
  reset-ticks
end

如果你想让你的海龟将边界视为封闭的,你可以让它们检查它们的 patch-ahead 无论它们的移动速度是多少(这里的示例速度为 1),然后做一个简单的数学运算来查看如果它们 'allowed' 在该边界处换行。要关闭左边界,请尝试:

to left-closed ; turtle procedure
  ask turtles [ 
    let target patch-ahead 1 
    if  ( ( [pxcor] of target ) - pxcor ) <= 1 [
      fd 1
    ]
  ] 
  tick  
end

要关闭右边界,你可以做相反的事情:

to right-closed ; turtle procedure
  ask turtles [ 
    let target patch-ahead 1 
    if  ( pxcor - ( [pxcor] of target ) ) <= 1 [
      fd 1
    ]
  ] 
  tick  
end

显然,这是一个非常简单的示例,需要一些工作来调整它以适应您当前的运动规则。

编辑:

要实际展示这一点,请查看此示例代码。首先,修改设置,指定海龟产卵的位置,并创建一个 'wall' 红色补丁:

to setup
  ca
  ask patches with [ pxcor = 5 ] [
    set pcolor red
  ]
  ask patch -5 0 [
    sprout 10 [
      pd
    ]
  ]
  reset-ticks
end

现在,上述 right-closed 过程的修改版本将其变成 to-report:

to-report closed-border-right? [ target-patch ]
  report ( pxcor - ( [pxcor] of patch-ahead 1 ) ) <= 1 
end

现在,我们应该预料到乌龟应该是过不了红墙的。他们也不应该能够越过右边界,但他们应该能够越过左边界。所以,如果海龟可以自由游荡,使用这个移动程序:

to move-example
  ask turtles [
    rt random 61 - 30
    let target patch-ahead 1
    if closed-border-right? target and [pcolor] of target != red [
      fd 1
    ]
  ]
  tick
end

我们应该期望它们最终会到达 'trapped' 展开的边界和红墙之间——正如我们预期的那样,一旦海龟穿过左边界,它们就无法返回: