在 netlogo 中处理 patch-here 时正确的语法是什么?

What is the proper syntaxis when dealing with patch-here in netlogo?

我有以下代码,但是当我尝试 运行 它时,我收到一条消息说“需要一个文字值”,它突出显示 calidad。 ..
我猜是因为我写括号的方式有问题?

to check-if-dead
 if habitat = "escarabajo" [
  ask escarabajos [
      if count escarabajos-here > capacidad-de-carga-bosques [die] ; beetles that reach patches that already have a # above the carrying capacity die 
      if patch-here = [calidad "baja"] [
        if random 100 > probabilidad-de-supervivencia-calidad-baja [die]
      ]
      if patch-here = [calidad "alta" ] [
        if random 100 > probabilidad-de-supervivencia-calidad-alta [die]
      ]
    ]
  ]

我的宇宙中有高质量的补丁和低质量的补丁,我希望海龟以一定的概率(由滑块确定)死亡,这取决于它们降落在哪个补丁上...

你可能想要 if [calidad] of patch-here = "baja":

to check-if-dead
  if habitat = "escarabajo" [
    ask escarabajos [
      if count escarabajos-here > capacidad-de-carga-bosques [die] ; beetles that reach patches that already have a # above the carrying capacity die 
      if [calidad] of patch-here = "baja" [
        if random 100 > probabilidad-de-supervivencia-calidad-baja [die]
      ]
      if [calidad] of patch-here = "alta" [
        if random 100 > probabilidad-de-supervivencia-calidad-alta [die]
      ]
    ]
  ]
end

但请注意,海龟总是生活在一个补丁上,因此您可以在这种情况下直接将 patches-own 变量作为 short-cut 引用(与使用 [=14= 相同的方式) ] 在海龟上下文中也是如此):

to check-if-dead
  if habitat = "escarabajo" [
    ask escarabajos [
      if count escarabajos-here > capacidad-de-carga-bosques [die] ; beetles that reach patches that already have a # above the carrying capacity die 
      if calidad = "baja" [
        if random 100 > probabilidad-de-supervivencia-calidad-baja [die]
      ]
      if calidad = "alta" [
        if random 100 > probabilidad-de-supervivencia-calidad-alta [die]
      ]
    ]
  ]
end