【问题标题】:Netlogo: Nothing named edge has been definedNetlogo:没有定义任何命名的边缘
【发布时间】:2020-05-16 05:04:22
【问题描述】:

我是 netlogo 的新手(版本:6.1.1)。我只是想创建一个围绕原点的补丁。但它提醒我“没有定义任何名为边缘的东西。”

to setup-center
  clear-all
  ask patches [
  if pxcor = (- (edge / 2)) and pycor >= (- (edge / 2)) and pycor <= (0 + (edge / 2))
  [set pcolor red]
  if pycor = (- (edge / 2)) and pxcor >= (- (edge / 2)) and pxcor <= (0 + (edge / 2))
  [set pcolor red]
  if pxcor = (edge / 2) and pycor >= (- (edge / 2)) and pycor <= (0 + (edge / 2))
  [set pcolor red]
  if pycor = (edge / 2) and pxcor >= (- (edge / 2)) and pxcor <= (0 + (edge / 2))
  [set pcolor red]
  ]
end

你能告诉我哪里出错了吗?感谢您的回复

【问题讨论】:

    标签: netlogo


    【解决方案1】:

    问题是edge 没有在 NelLogo 中定义。相反,世界的边缘由min-pxcormax-pxcormin-pycormax-pycor 描述。因此,您的程序(稍微简化)将是

    to setup-center
      clear-all
      let top max-pycor / 2
      let bottom min-pycor / 2
      let left-side min-pxcor / 2
      let right-side max-pxcor / 2
      ask patches [
        if pxcor = left-side and pycor >= bottom and pycor <= (0 + top)
        [set pcolor red]
        if pycor = bottom and pxcor >= left-side and pxcor <= (0 + right-side)
        [set pcolor red]
        if pxcor = right-side and pycor >= bottom and pycor <= (0 + top)
        [set pcolor red]
        if pycor = top and pxcor >= left-side and pxcor <= (0 + right-side)
        [set pcolor red]
      ]
    end
    

    这种方法查询世界上的每个补丁,如果世界很大,效率相对较低。但是,对于相当小的世界,它运行良好,并且在设置中您只需要执行一次。

    希望这会有所帮助, 查尔斯

    【讨论】:

    • 已经解决了。谢谢你的帮助,教授
    猜你喜欢
    • 2017-04-12
    • 1970-01-01
    • 1970-01-01
    • 2017-07-06
    • 1970-01-01
    • 1970-01-01
    • 2018-04-15
    • 2018-09-24
    • 2014-01-17
    相关资源
    最近更新 更多