Properties & globals

There are two kinds of named state in a model.

Properties

Each agent type and the patches collection can declare properties. They are per-instance: every agent of that type gets its own copy.

sheep: { properties: [
  { name: 'energy', type: 'number', default: 'random(10, 50)' }
]}

The default is a DSL expression that runs once for each instance at setup. Inside rules you can read and write the property as a bare name (energy = energy + 1) or as me.properties.energy if you need to disambiguate.

Globals

Globals are model-wide values bound to a widget on the Interface tab:

  • Slider - a number with min / max / step.
  • Switch - a boolean.
  • Chooser - one value from a list of choices.
  • Input - a free-form string or number.

Globals are read in rules as bare identifiers - a slider grass_regrow_rate appears as grass_regrow_rate inside an expression. They can be tweaked live while the simulation is running.

Naming

Property and global names must be valid identifiers (letters, digits, underscore, can't start with a digit) and unique inside their scope. The form will reject reserved words and duplicates inline.