Marzy
Marzy

Reputation: 1894

What is the most efficient way to ask other turtle who can see the caller turtle in NetLogo?

I was wondering if anyone has a good idea to filter turtles who have the caller turtle in their vision and in their cone of vision with the least computational cost?

Now I am using something like this:

Member? Caller-Agent agents in-cone 5  100

or just who are agents who can see me? I was wondering if anyone knows how can I check if heading of other agents in some radius X is toward the caller agent ?

Upvotes: 0

Views: 230

Answers (1)

Marzy
Marzy

Reputation: 1894

So , this is the way I did it:

I used abs( towards myself - heading) < 50

I thought it might include cone with angle of 100 since it uses absolute value.

This is just a test program to see if it works:

ask turtles[set label "" set color green]
ask turtle 7 [ 
set color red
set label "Caller"

ask other (turtles with [distance myself <= 3 and abs( towards myself - heading) < 50 ])
[

set color yellow
]

ask other turtles [

set label (Member? turtle 7 Other turtles  in-cone 3  100)
]
]

Cone 100

and this one cone 80 and abs( towards myself - heading) < 40 : enter image description here

There is a problem with this approach: if an agent is as same location of the caller then I will get the error that there is no heading defined to same point or something like that!

Error is : No heading is defined from a point (7,7) to that same point. error while turtle 28 running TOWARDS

Update:

[(distance myself <= 3 and distance myself > 0 and abs(  subtract-headings towards myself   heading ) < 60) or distance myself = 0 ]

enter image description here

Upvotes: 1

Related Questions