【问题标题】:How can I ask a turtle to count the number of other turtles which have a turtle-own value bigger than myself?我如何让乌龟计算其他乌龟的数量比自己的乌龟拥有值大?
【发布时间】:2019-06-28 18:03:44
【问题描述】:

如何让乌龟算出其他乌龟拥有的乌龟拥有值比自己大的数量?

我做了一个行人评估模拟。在这个模型中,有一个turtle-own value [dis-door1],表示从turtle到door1的距离。我必须计算 [dis-door1] 比我小的其他海龟的数量,但我失败了。这是我试图这样做的代码:

ask people[
  set dis-door1 distancexy 15 0
  set dis-door2 distancexy 0 15
  set density1 (count people with [([dis-door1] of other people) < ([dis-door1] of myself)]) / [dis-door1] of myself
  set density2 (count people with [([dis-door2] of other people) < ([dis-door2] of myself)]) / [dis-door2] of myself
  ]

我希望有人可以帮助做到这一点。

【问题讨论】:

    标签: netlogo


    【解决方案1】:

    您的代码大部分是正确的。

    试试下面的。本质上,我删除了我自己的外部,因为我自己是谁的引用是指调用者的调用者——你可以直接访问 ask people [...here...] 范围内的 dis-door1

    ask people[
      set dis-door1 distancexy 15 0
      set dis-door2 distancexy 0 15
      set density1 (count people with [([dis-door1] of other people) < ([dis-door1] of myself)]) / dis-door1
      set density2 (count people with [([dis-door2] of other people) < ([dis-door2] of myself)]) / dis-door2
      ]
    

    【讨论】:

      猜你喜欢
      • 2017-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-04
      • 2020-03-03
      • 1970-01-01
      相关资源
      最近更新 更多