1

I'm currently modeling some simple boids using Netlogo3d and i'm having an issue with the in-cone and in-radius functions.

(I'm re-implementing the article 'Collective Memory and Spatial Sorting in Animal Groups' from Couzin, Krause, James, Ruxton and Franks)

i use three different area around my boids to define its behaviour : One for repulsion, one for attraction and one for orientation. Thoses three are sphere around the boid Thoses areas look like this I'm detecting turtles in thoses area like this :

to find-flockmates-repulsion  ;; turtle procedure
  set flockmatesRepulsion other turtles in-cone (visionRepulsion * scale) fov
end
to find-flockmates-orientation  ;; turtle procedure
  set flockmatesOrientation other turtles in-cone ((visionOrientation + visionRepulsion) * scale) fov
end
to find-flockmates-attraction  ;; turtle procedure a modifier pour enlever les turtles dans le radius visionOrientation
  set flockmatesAttraction other turtles in-cone ((visionAttraction + visionOrientation + visionRepulsion) * scale) fov
end

But those three areas are overlapping and i don't want them to overlap.

Is there a way to reduce the selection of the in-cone and in-radius function like :

set flockmatesAttraction other turtles [ (in-cone ((visionAttraction + visionOrientation + visionRepulsion) * scale) fov) and not (in-cone ((visionOrientation + visionRepulsion) * scale) fov) ]

And if possible not with a loop on 2 lists, I'm trying to make my boids efficient Thank you!

(PS : Sorry for the broken english)

IBeLow
  • 11
  • 1

1 Answers1

1

Rather than finding a modification of in-cone, which I'd think is written to be efficient, you might simply compute your three agent sets as you did in the question, and then remove the smaller agent-set from the larger one to get the difference agent-set, which is what you are after.

So you'd do this:

to find-flockmates-repulsion  ;; turtle procedure
  set flockmatesRepulsion other turtles in-cone (visionRepulsion * scale) fov
end
to find-flockmates-orientation  ;; turtle procedure
  set flockmatesOrientation other turtles in-cone ((visionOrientation + visionRepulsion) * scale) fov
end
to find-flockmates-attraction  ;; turtle procedure a modifier pour enlever les turtles dans le radius visionOrientation
  set flockmatesAttraction other turtles in-cone ((visionAttraction + visionOrientation + visionRepulsion) * scale) fov
end

;; and then remove the overlap using the member? reporter
set flockmatesAttraction flockmatesAttraction with [not member? self flockmatesOrientation ]

By the way I used the answer that Charles posted of how to subtract one agent set from another Removing an agentset from another agentset (the agents from the first set which are also present in the second set) in which he said:

I think what you want is the member? primitive. If D and B are agentsets, the following should give you the members of D that are not members of B.

let DminusB D with [not member? self B]

Wade Schuette
  • 1,455
  • 1
  • 8
  • 9