Search code examples
netlogoticker

Set ticker to zero in netlogo


I had problem with ticker in netlogo. I want to reset ticker to zero. But when you reset ticker with "reset-tickers" command, all the variables, plots and ... will reset to zero too, but this is not pleasant for me. I want just reset the ticker and set it to zero without resetting other variables and .... How can I do that?

Thanks


Solution

  • The reset-ticks primitive does, indeed, set up and update all plots. It does not, however, reset all variables (clear-all does that).

    In any case, you should see ticks as representing time in your model. And time cannot flow backward. Resetting ticks will always be the equivalent of "starting over" with a brand new run of your model.

    If you want some counter that you can reset to zero without affecting anything else, tough, it's easy to make one yourself.

    First, declare a global variable:

    globals [ my-counter ]
    

    Somewhere in your setup procedure, set that variable to 0:

    set my-counter 0
    

    Somewhere in your go procedure, increment it:

    set my-counter my-counter + 1
    

    And whenever you want to "reset" your counter, just set it to 0 again like you did at setup:

    set my-counter 0