NetLogo Help: max-n-of

### max-n-of4.0

#### max-n-of number agentset [reporter]

Reports an agentset containing number agents from agentset with the highest values of reporter. The agentset is built by finding all the agents with the highest value of reporter, if there are not number agents with that value then agents with the second highest value are found, and so on. At the end, if there is a tie that would make the resulting agentset too large, the tie is broken randomly.

    ;; assume the world is 11 x 11
    show max-n-of 5 patches [pxcor]
    ;; shows 5 patches with pxcor = max-pxcor
    show max-n-of 5 patches with [pycor = 0] [pxcor]
    ;; shows an agentset containing:
    ;; (patch 1 0) (patch 2 0) (patch 3 0) (patch 4 0) (patch 5 0)

See also max-one-of, with-max.

Take me to the full NetLogo Dictionary