1

I need to find the minimum distance between patches in front of my agent to a certain patch (goal), in order to select the patch that would create the most optimal (shortest) path. The primitive distance only requires one argument so I can't use it as is for this function.

Gannicus
  • 530
  • 1
  • 7
  • 26

1 Answers1

6

The distance primitive only requires one argument, yes, but it is a "patch or turtle primitive": it must be run in the context of a particular agent by "asking" it for its distance to another, so you can think of the context in which it run as another argument.

If you want to know the distance between patch 0 0 and patch 1 1, you can write:

ask patch 0 0 [ show distance patch 1 1 ]

or, likely more useful:

[ distance patch 1 1 ] of patch 0 0
Nicolas Payette
  • 14,847
  • 1
  • 27
  • 37
  • 1
    I didn't even know the second statement is possible in NetLogo. I really should expose myself to more algorithms so I would have more reference than the NetLogo dictionary. Thank you so much! – Gannicus Apr 14 '13 at 15:42
  • I would suggest perusing the model library. Most models are simple enough that they can be understood in a few minutes. Just look at the code, and read up on anything that you have not seen before. – Nicolas Payette Apr 14 '13 at 15:48