Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Netlogo how can I make something happen every 1000 ticks

Tags:

netlogo

I have a model of tax evasion where the taxes should be payed each round, e.g. each 1000 ticks. As a placeholder, I have this code

ask traders with [ticks  = 1000 or ticks = 2000 or ticks = 3000];; Can this be set using a seed?
    [reset-parameters
       pay-taxes
       revise-behavior
       reset-turnover]

In SQL, I would have set done something like this:

FOR I IN 1..3000 LOOP ask traders with ticks = I*1000

Is there a similar function in Netlogo? Any other tips on how to make something happen every 1000 ticks?

like image 953
Ullsokk Avatar asked Jan 11 '23 16:01

Ullsokk


1 Answers

Your own solution will work, but is not optimal.

Since ticks is a global NetLogo reporter, and not a traders variable, the value returned by ticks mod 1000 = 0 does not vary with each trader. It will either be true for all of them or false for all of them, so there is no use putting in in a with clause (where it will be re-evaluated for each trader).

It would be faster (and clearer) to just do:

if ticks mod 1000 = 0 [
  ask traders [
    do-something
  ]
]
like image 92
Nicolas Payette Avatar answered Mar 20 '23 07:03

Nicolas Payette