netlogo:比较海龟变量

netlogo: Comparing turtles variables

我正在模拟两支军队面对面的情况。为了区分两支军队,我设置了一个变量 ex 来检查乌龟的邻居中是否有敌人。

这是我的:

breed [sols sol]
sols-own[en ex nvic]

这是我尝试做的(失败):

ifelse any? sols-on neighbors with [ex != ([ex] of myself)]
[
;fight
]
[
;move
]

但是 with 正在检查那些补丁而不是海龟,我不知道该怎么做。

非常感谢您的帮助,

提前致谢

我认为您可以通过在 sols-on neighbors 周围加上括号来指定您尝试使用 with:

评估的代理集
breed [sols sol]
sols-own[ex]

to setup  
  ca
  create-sols 20 [
    setxy random-pxcor random-pycor
    set ex "good"
    set color blue
  ]
  ask n-of 10 sols [
    set ex "evil"
    set color red
  ]
  reset-ticks  
end


to detect-enemies
  ask sols [
    ifelse any? ( sols-on neighbors ) with [ ex != [ex]  of myself ] [
      print "ENEMY DETECTED"
    ] [
      fd 1
    ]
  ]
  tick  
end