0

How can I estimate the duration an agent stays in a specific state in a state chart? I want to count the number of times an agent enters a state and the duration before the transition us triggered to the other state

1 Answers1

0

Easiest way:

  1. create a variable timerState of type double.
  2. On entry of the state: timerState=time();
  3. On Exit of the state: double timeInState = time()-timerState;

Then do what you want with that timeInState value.

Be VERY careful with this, though. You should not use the timerState variable for anything else.

Benjamin
  • 10,603
  • 3
  • 16
  • 28