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 State
Section titled “Hidden State”hidden name: min..max = initialHidden states are invisible to the brain - the agent cannot sense them. They participate in rules but never appear as sensor inputs.
Operators
Section titled “Operators”| Operator | Meaning | Example |
|---|---|---|
+= | Add to current value | hunger += 0.003 |
-= | Subtract from current value | energy -= 0.008 |
*= | Multiply current value | nausea *= 0.95 |
= | Set to value | health = 0.0 |
Conditions
Section titled “Conditions”| Operator | Meaning |
|---|---|
> | Greater than |
< | Less than |
>= | Greater than or equal |
<= | Less than or equal |
Expressions
Section titled “Expressions”Right-hand side of an assignment can be:
| Form | Example |
|---|---|
| Literal value | hunger += 0.003 |
| Unary minus | energy += -0.1 |
| State reference | energy = health |
number * state_ref | damage += 0.5 * sickness |
number * (expr) | stress += 0.001 * (1.0 + fatigue * 2.0) |
state * value | damage = sickness * 0.5 |
state + value | recovery = health + 0.1 |
state - value | penalty = energy - 0.2 |
| Parenthesized sub-expression | energy -= (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_tickrules run unconditionally every tickrulesblock contains conditional rules evaluated in orderdeathconditions are checked after all rules apply; if any is true the agent diesclampapplies to all states after each tick- Note: Parameters must be named. Write
trigger(threshold: 0.5)nottrigger(0.5).