Javier Sandoval
Javier Sandoval

Reputation: 507

Netlogo: finding min variable of patches at certain radius of patch

I'm trying to estimate slopes between patches, so need to find the minimum value of a patch variable called Elevation from all patches that are at radius 4 from a specific patch. Here is the code:

ask patch 27 35 [let x min-one-of patches in-radius 4 [Elevation]
                 print x]

but instead of the lowest value of Elevation, it prints: (patch 27 31). What can I do to have the value instead of coordinates?

Upvotes: 1

Views: 326

Answers (1)

JenB
JenB

Reputation: 17678

You've got the code to find the patch with the minimum value, so all you need is the value at that patch.

ask patch 27 35
[ let low-patch min-one-of patches in-radius 4 [Elevation]
  let x [Elevation] of low-patch
  print x
]

But it's more straightforward to just take the minimum of the values directly (not tested so syntax may need to be adjusted)

ask patch 27 35
[ let x min [Elevation] of patches in-radius 4
  print x
]

Upvotes: 2

Related Questions