Netlogo 如果没有工作

Netlogo 如果没有工作,netlogo,Netlogo,请检查这个代码。哪一部分错了 to catch-lizards let prey one-of lizards-here ifelse prey = "lizard2" [ show "WRONG" ask prey [die] set lifetime = lifetime + hawks-life-gain ] [ifelse droping-tail? = true [ask prey [set shape "lizard2" se

请检查这个代码。哪一部分错了

to catch-lizards
    let prey one-of lizards-here
    ifelse prey = "lizard2"
    [ show "WRONG" ask prey [die]
     set lifetime = lifetime + hawks-life-gain ]
    [ifelse droping-tail? = true
    [ask prey [set shape "lizard2"
    set lifetime lifetime + hawks-life-gain / 4 ] ]
    [ask prey [die]
    set lifetime lifetime + hawks-life-gain ]
   ]
  ]
end

问题出现在写(显示“错误”)的地方。那部分不起作用。语法不正确吗?

ifelse-prey=“lizard2”
部分,比较
prey
是否为字符串
lizard2
。但是猎物不是一根绳子,它是一个具有某些属性的物体,如
形状
寿命

所以你需要询问猎物的形状是否是蜥蜴2

更新:检查猎物的形状可能如下所示:

ask prey [
  ifelse shape = "lizard2" [
    …
  ] [
    …
  ]
]

我想检查猎物的形状是否是蜥蜴2。这就是条件。我该怎么做?猎物是agentset,蜥蜴1、蜥蜴2是它的形状。我想在某些条件下交换这些形状。