Reputation: 1067
I have more turtles moving in the world, i would like to get them connected when they are inside an area (circles).
This is an example:
I was trying with a function like this, called in the "go" procedure (tick advanced) but this doesn't work. Any suggestion?
to connect
ask turtles in-radius radius [
create-link-from myself
create-link-to myself
]
end
Upvotes: 1
Views: 617
Reputation: 17678
If I have understood what you want, this will work
globals [radius]
to setup
clear-all
create-turtles 50 [setxy random-xcor random-ycor]
set radius 5
connect
end
to connect
ask turtles
[ ask other turtles in-radius radius
[ create-link-from myself
]
]
end
The problem is that you have ask turtles in-radius ...
but you don't specify the reference point. That is, within a certain distance of what? In my code, I ask each turtle to become the reference point and then ask the turtles within distance of itself to do the linking.
Upvotes: 1