Reputation: 31
How can I ask a turtle to count the number of other turtles which have a turtle-own value bigger than myself?
I made a pedestrian evaluation simulation. In this model, there is a turtle-own value [dis-door1]
, meaning the distance from turtle to door1. I have to count the number of other turtles which have a [dis-door1] smaller than myself, but I failed. Here is the code with which I am trying to do that:
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
]
I hope somebody can help to do that.
Upvotes: 3
Views: 56
Reputation: 3806
Your code is mostly correct.
Try the below. Essentially, I removed the outside the of myself because the reference of who myself is refers to the caller of the caller---you have direct access to dis-door1 in the scope of 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
]
Upvotes: 4