我该如何要求一只乌龟对自己拥有的比自己大的其他乌龟的数量进行计数?
我进行了行人评估模拟。在此模型中,有一个turtle-own value [dis-door1]
,表示从乌龟到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
]
我希望有人可以帮忙。
答案 0 :(得分:4)
您的代码大部分是正确的。
尝试以下方法。本质上,我删除了我自己的外部,因为我自己的引用是指呼叫者的呼叫者-您可以直接访问ask people [...here...]
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
]