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.
Methods
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.
Object Properties
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
The
Paramobject whose value to shock.paramcan also be set toNone, in which casevalFuncbehaves somewhat differently. See below.valFunc — func
A function that returns a new value for the parameter.
valFunctakes three arguments: the name of the variable being shocked, the parameter type (Nonefor global parameters,'breed'or'good'for per-breed and per-good parameters, respectively), and (for per-breed or per-good parameters) the breed or the good in question. IfparamisNone, however,valFunctakes 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
valFuncthat period or not.timerFunccan also be set to the string'button', in which case a button will be drawn in the control panel that runsvalFuncwhen 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.
Notes and Examples