Properties & globals
There are two kinds of named state in a model.
Properties
Each agent type, and the patches, can have properties. Every agent of that type, or every patch, gets its own value.
sheep: { properties: [
{ name: 'energy', type: 'number', default: 'random(10, 50)' }
]}
The default is a DSL expression that runs once for each agent at setup. In rules you read and write the property as a bare name (energy = energy + 1). Write me.properties.energy when another name is the same.
Globals
Globals are values of the whole model, each with a control on the Interface tab:
- Slider: a number with a min, max and step size.
- Switch: on or off.
- Chooser: one value from a list.
- Input: any text or number.
Rules read a global by its bare name. A slider grass_regrow_rate is grass_regrow_rate in an expression. You can change globals while the model runs.
Naming
A property or global name uses letters, digits and underscores, and does not start with a digit. It must be unique in its scope. The form refuses reserved words and names already taken.