Reference 〉Class

Shock( )

A data structure to store information on individual shocks, stored in Shocks.shocks. Should not be instantiated directly; use Shocks.register() 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.

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. Note that tooltips require PMW when using the Tkinter frontend.

  • param Param

    The Param object whose value to shock. param can also be set to None, in which case valFunc behaves somewhat differently. See below.

  • valFunc func

    A function that returns a new value for the parameter. valFunc takes three arguments: the name of the variable being shocked, the parameter type (None for 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. If param is None, however, valFunc 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 valFunc 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 runs valFunc 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.

Notes and Examples

  1. Contribute a Note

    Your email address will not be published. Required fields are marked *

    You may use limited HTML for formatting. Please embed blocks of code in <pre><code> </code></pre> tags.

History