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. Read and write with self.energy (or just energy inside a CodeBlock).

Globals

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

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.

Try it in the app

Everything described here works in the live editor. Open Stigmery and follow along.

Open the app →