Search code examples
netlogomonitor

NetLogo: Monitor variable of turtle


I have a breed "robots" and I create a single robot with health 0.

breed [robots robot] 
create-robots 1 [
  set health 0
]

Now I want to track the robot's health during runtime. I've tried many things like

[ health ] of robot 0

But it just doesn't seem to work, the monitor just shows "N/A" like below.

enter image description here

Any idea?


Solution

  • There's nothing wrong with your code (or the bit you've shown anyway). Have you actually run the procedure that the create is inside of? Here's is a complete model:

    breed [robots robot]
    robots-own [health]
    
    to setup
      create-robots 1
      [ set health 0
      ]
    end
    

    If you have a monitor with [ health ] of robot 0 it will show N/A initially. As soon as you run the setup procedure (with a button call, or from the command center), it changes to 0.