Skip to content

Dynamics

Defines per-tick state cascade rules - how internal states change over time independent of agent actions. Dynamics is optional; omitting it means no per-tick state changes.

Dynamics are the physics of your simulation - the rules that govern what happens every tick regardless of what the agent does. This is where you model things like hunger slowly increasing, sickness spreading, or healing over time. Without dynamics, the world is static: nothing changes unless the agent acts. With dynamics, the world exerts constant pressure that the agent must respond to in order to survive.

dynamics Metabolism {
// Hidden state - brain can't sense these
hidden total_damage: 0..1 = 0.0
// Per-tick rules - applied every tick unconditionally
per_tick {
hunger += 0.003
thirst += 0.005
}
// Conditional rules - applied in order when condition is met
rules {
if hunger > 0.7: energy -= 0.008
if energy >= 0: energy -= 0.002
if hunger > 0.85: health -= 0.005
if nausea >= 0: nausea *= 0.95
}
// Agent dies when any condition is true
death {
if health <= 0
}
// All states clamped to this range after each tick
clamp 0..1
}
hidden name: min..max = initial

Hidden states are invisible to the brain - the agent cannot sense them. They participate in rules but never appear as sensor inputs.

OperatorMeaningExample
+=Add to current valuehunger += 0.003
-=Subtract from current valueenergy -= 0.008
*=Multiply current valuenausea *= 0.95
=Set to valuehealth = 0.0
OperatorMeaning
>Greater than
<Less than
>=Greater than or equal
<=Less than or equal

Right-hand side of an assignment can be:

FormExample
Literal valuehunger += 0.003
Unary minusenergy += -0.1
State referenceenergy = health
number * state_refdamage += 0.5 * sickness
number * (expr)stress += 0.001 * (1.0 + fatigue * 2.0)
state * valuedamage = sickness * 0.5
state + valuerecovery = health + 0.1
state - valuepenalty = energy - 0.2
Parenthesized sub-expressionenergy -= (hunger + thirst)

Operator precedence: * binds tighter than + and -. Use parentheses to override precedence when needed.

  • Rule ordering matters - earlier rules’ effects are visible to later rules within the same tick
  • per_tick rules run unconditionally every tick
  • rules block contains conditional rules evaluated in order
  • death conditions are checked after all rules apply; if any is true the agent dies
  • clamp applies to all states after each tick
  • Note: Parameters must be named. Write trigger(threshold: 0.5) not trigger(0.5).