SJ19
SJ19

Reputation: 2123

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?

Upvotes: 0

Views: 853

Answers (1)

JenB
JenB

Reputation: 17678

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.

Upvotes: 4

Related Questions