Agent Types

In Loom, agent types are called archetypes. Each archetype becomes a Python class that extends Mesa's Agent base class.

Defining an Archetype

An archetype has two main parts:

  • Properties — Typed instance variables with default values
  • Behaviors — Visual graphs that define step logic

Double-click an archetype name to rename it. The name becomes the Python class name (e.g., "Predator" → PredatorAgent).

Properties

Properties are typed fields on the agent. Click + in the Properties section to add one.

Primitive Types

Type Python Type Example Use
int int Age, health points
float float Energy, speed, wealth
bool bool Is alive, has immunity
str str Name, state label

Collection Types

Type Python Type Example Use
list list Inventory items, visited positions
dict dict Attribute maps, neighbor relationships
tuple tuple Coordinates, fixed-size records
set set Unique tags, membership groups

Special Types

Type Python Type Example Use
enum str (Enum) Agent state (idle/moving/done)
any Any Generic data, pass-through values

Properties can be read with Get Property and written with Set Property nodes inside behaviors. You can also drag the G (get) and S (set) handles from the property list directly onto the canvas.

Ordering

The order of archetypes determines the order agents are created at initialization. Use the up/down arrows (visible on hover) to reorder archetypes and behaviors. Behavior order matters — it controls the call sequence in the generated step() method.

Multiple Archetypes

Models can have multiple archetypes. Each archetype is independent — they have their own properties and behaviors. Agents of different types can interact through spatial queries like Get Neighbors.