A data structure to store information on individual shocks, stored in the Shocks
object, itself stored in model.shocks
. Should not be instantiated directly; use Shocks.add()
instead. The properties of this object correspond to arguments of that function.
Click a method name for more detailed documentation.
do( model )
Execute a shock upon the model. Should not be called directly; this function is called in the course of the model step function.
name — str
The short and unique name of the shock, used throughout the code to refer back to it.
desc — str
A long description to display as a tooltip.
param — Param
object whose value to shock.param
can also be set toNone
, in which casevalFunc
behaves somewhat differently. See below.valFunc — func
A function that returns a new value for the parameter.
takes three arguments: the name of the variable being shocked, the parameter type (None
for global parameters,'breed'
for per-breed and per-good parameters, respectively), and (for per-breed or per-good parameters) the breed or the good in question. Ifparam
takes one argument, the model object. This can be useful for more complex shocks that do not correspond to a particular parameter.timerFunc — func(int)|str
A function that takes the current model time and returns a bool, indicating whether to run
that period or not.timerFunc
can also be set to the string'button'
, in which case a button will be drawn in the control panel that runsvalFunc
when the button is pressed.item — str
Specifies the breed or the good whose parameter ought to be shocked if the parameter is a per-breed or per-good parameter.
active — bool
Whether the shock is currently active, i.e. the state of the checkbox in the control panel.