I wonder if anyone can help with this question for which I am a bit lost. I have turtles with three-dimensional boolean lists [a b c]
where a, b, c in {0, 1}
. I would like each turtle to create a link with another one who has 1
on all the same positions of the list. A turtle should thus identify where in its list it has 1
and look for another turtle that has 1
in the every same position. Where the original turtle has 0
, the second one can have either 1
or 0
.
That is:
Turtle 1 [0 1 0]
Turtle 2 [1 1 1]
Turtle 3 [1 0 1]
Turtle 4 [0 1 1]
Turtle 1 should create links with Turtle 2 or Turtle 4 (because both have 1
on item 1
, the second position) but not with Turtle 3 since it has a 0
in that position. Turtle 4 should create a link with Turtle 2 only (1
in the second and third positions), as should Turtle 3 (1
in the first and third position), and Turtle 2 should be unable to create links (no turtles with 1
in all three positions).
What I have is
let candidate one-of turtles with [list1 = [list1] of myself]
create-link-with candidate
Which of course doesn't work since the turtle will look for another one that has exactly the same list (including zeros) and not one that has the same positions for 1
only. I know this should be related to foreach
, map
, reduce
and filter
but I can't quite get the syntax right...
Happy end of year to everyone