Frage

How does one access the link object at the current location of a turtle? For instance to count the number of times an event occurs while traversing a particular link.

I had (perhaps stupidly) assumed that you could:

ask link(s)-here [set count count + 1]

But link-here is not a method and that doesn't work.

Any advice much appreciated
Many thanks for reading.

Stephen

War es hilfreich?

Lösung

Are your turtles just wandering around the plane and sometimes happen to cross over some links? If so, see Bryan's answer.

Or, are your turtles actually intentionally walking along the links? If the latter, then add:

turtles-own [current-link]

and at the time the turtle chooses the link and begins following it, store the link in that variable.

Andere Tipps

This answer shows how to get the distance to a link: https://stackoverflow.com/a/22163018/145080

You could then do something like:

to-report links-here
  report links with [ link-distance [pxcor] of myself [pycor] of myself < .5 ]
end

Note that this won't detect links passing through the edges of the patch. Play with the distance (currently .5) to get how you want it.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top