netlogo comparing turtle variables

人走茶凉 提交于 2020-01-05 11:37:00

问题


I'm writing a program which groups turtles into different groups. I am trying to write a command where if there is a turtle in a different group within a 1 until radius of the turtle the command runs.

This is what I have

to confront
  ask turtles
   [if [ group ] of turtles in-cone 1 180 != group  
    [set color brown]]
end

However the command is coming out true even when there is not a turtle in a different group nearby.


回答1:


may be something like :

to confront
  ask turtles
   if any? turtles in radius 2 [
     if any? turtles in radius 2 with [group != [group] of myself][
      set color brown
     ]
   ]
end

I don't know if it can work directly (I haven't test this code) but I think it's a way



来源:https://stackoverflow.com/questions/28770317/netlogo-comparing-turtle-variables

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!