For example:
Turtle 1 have link-neighbors [2, 3] and Turtle 2 have link-neighbors [1, 3, 4].
I want Turtle 1 to create link with one of Turtle 2's link-neighbors, but don't want Turtle 1 to create a link with itself (Turtle 1) or his existing link-neighbor (Turtle 2) - only Turtle 4 qualifies this condition.
And I want to write a "to go" function that asks all my N turtles to do this, like:
to go:
ask turtles [ make-friends ]
end
to make-friends
;; turtle create a link with one of its link-neighbors' link-neighbor
;; who can not be its link-neighbor or itself
end
Would the following do? turtle 1 would
let targets [link-neighbors] of turtle 2
let exclude link-neighbors
set targets other targets with [NOT member? self exclude]
create-link-to one-of targets
targets would first be the link-neighbors of turtle 2. We then want to exclude turtle 1's own link neighbors, so we look for targets that are not in the excluded set, other than than turtle 1 itself. Finally choose one to link to. (We may need to check at each step to be sure that targets and exclude are not empty.)