NetLogo Help: who

### who

This is a built-in turtle variable. It holds the turtle's "who number" or ID number, an integer greater than or equal to zero. You cannot set this variable; a turtle's who number never changes.

Who numbers start at 0. A dead turtle's number will not be reassigned to a new turtle until you use the clear-turtles or clear-all commands, at which time who numbering starts over again at 0.

Example:

    show [who] of turtles with [color = red]
    ;; prints a list of the who numbers of all red turtles
    ;; in the Command Center, in random order
    crt 100
      [ ifelse who < 50
          [ set color red ]
          [ set color blue ] ]
    ;; turtles 0 through 49 are red, turtles 50
    ;; through 99 are blue

You can use the turtle reporter to retrieve a turtle with a given who number. See also turtle.

Note that who numbers aren't breed-specific. No two turtles can have the same who number, even if they are different breeds:

    clear-turtles
    create-frogs 1
    create-mice 1
    ask turtles [ print who ]
    ;; prints (in some random order):
    ;; (frog 0): 0
    ;; (mouse 1): 1

Even though we only have one mouse, it is `mouse 1` not `mouse 0`, because the who number 0 was already taken by the frog.

Take me to the full NetLogo Dictionary