who

who
Turtle Command

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.

Take me to the full NetLogo Dictionary