I have turtles linking if they have an equal value for var1 (this works fine). I want to limit the number of links to just three. I added an IF statement before the linking part of the code (If count my-links < 3
), but it does not work; the agents continue to link past the max value I set. I read the other question How to limit the number of links an agent can make in a model but that doesn't seem to quite do what I am attempting here. What am I doing wrong?
to communicate
If count my-links < 3
[
ask other xagents in-radius 5 with [var1 = [var1] of myself]
[create-links-with yagents in-radius 5 with [var1 = [var1] of myself]
[
set color white
set thickness 0.1
]
]
]
end