netlogo比较乌龟变量 [英] netlogo comparing turtle variables

查看:102
本文介绍了netlogo比较乌龟变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个程序,将海龟分为不同的组。
我正在尝试编写一个命令,如果在1个不同的组中有一个乌龟,直到乌龟半径范围内,该命令就会运行。

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.

这就是我所拥有的

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.

推荐答案

可能类似于:

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

这篇关于netlogo比较乌龟变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆