1

In Netlogo, how can I create an agentset for a turtle that contains all other turtles except them and their in-link-neighbors?

Thank you,

Thomas

This is so close to creating an agentset of turtles excluding neighbors, but doesn't quite work:

to setup
  ca
  create-turtles 10 [setxy random-xcor random-ycor]
  ask turtles[create-link-to one-of other turtles]
end

to go
  ask one-of turtles[
    show in-link-neighbors
    let poss turtles with [not member? self in-link-neighbors]
    show poss 
  ]
end

The above code came from: this previous answer

Community
  • 1
  • 1
ThomasC
  • 861
  • 6
  • 12
  • Are you just looking for `other`? https://ccl.northwestern.edu/netlogo/docs/dictionary.html#other – Alan Mar 21 '17 at 14:47

2 Answers2

1

This will do the job, although it's not pretty.

to setup
  ca
  create-turtles 10 [setxy random-xcor random-ycor set color yellow set shape "circle"]
  ask turtles[create-link-to one-of other turtles]
end

to go
  ask one-of turtles[
    set color green
    ask in-link-neighbors [set color green]
    ask one-of turtles with [color != green] [set shape "person"]
  ]
  ask turtles [set color yellow]
end
ThomasC
  • 861
  • 6
  • 12
0

The most straightforward way is:

turtles with [not link-neighbor? myself]

Here's an example showing this in action:

observer> crt 10 [ create-links-with other turtles ]
turtles> fd 10
observer> ask turtle 0 [ show link-neighbors ]
(turtle 0): (agentset, 9 turtles)
links> if random 2 = 0 [ die ]
observer> ask turtle 0 [ show link-neighbors ]
(turtle 0): (agentset, 7 turtles)
observer> ask turtle 0 [ show turtles with [not link-neighbor? myself]]
(turtle 0): (agentset, 3 turtles)

That's for undirected links. If your links are directed, substitute in-link-neighbor? or out-link-neighbor?, as appropriate.

Seth Tisue
  • 29,985
  • 11
  • 82
  • 149
  • Thanks this will be useful, but I think it's for undirected neighbours? Is there a version for in-links or out-links? – ThomasC Mar 21 '17 at 15:02