Reputation: 11
I'm trying to create a variable in Netlogo that changes based on its value last tick. I've followed this question thread in how to create such a variable, but I'm having a bit of trouble creating the initial conditions, because at tick=0, there is no myvar-last-tick because there was no last tick, so Netlogo autosets myvar-last-tick to 0. How can I create myvar and myvar-last-tick such that when tick=0, myvar-last-tick is the same as myvar only at tick 0? To be clear I would like to program the variables such that they follow a pattern like this, although for my actual program the rate of decline would not be constant like in this example.
Upvotes: 1
Views: 44
Reputation: 9620
Before you call your go
procedure (i.e., your schedule), you should call a setup
procedure. Usually, the very first thing your setup
procedure should do is all of your global-variable initializations (perhaps by calling a setup-globals
procedure). You can initialize myvar-last-tick
and myvar
to anything you like. Just make sure the the result of your first call to go
will produce the starting outcome you want.
Upvotes: 2