Behaviour guide

A species is driven by one behaviour program: either a state machine (kind: "fsm") or a behaviour tree (kind: "bt"). Both share one vocabulary of predicates (conditions) and actions, defined in schema/v0.1/behavior-program.schema.json. Most species should reach for one of the three shared programs in behaviors/ (shown in full below) and override its params; write a species-local behavior.json only when none of them fit.

Finite state machines

One state is active at a time. Each tick:

  1. Every transition is checked in priority order, highest first; ties keep the order they appear in the file. from: "*" matches any current state. The first transition whose when predicate holds fires — at most one transition per tick — and the machine moves to its to state.
  2. A state's min_dwell_s blocks any transition out of it whose priority is ≤ 0 (the default, when a transition has no priority) until that many seconds have passed in the state. Transitions with priority > 0 (for example, fleeing a threat) can always interrupt, dwell time or not.
  3. Then the now-active state's action runs for this tick. If an action fails (its target vanishes, its resource is gone), the machine returns to initial rather than staying stuck.

Behaviour trees

The whole tree is ticked from the root every tick — there is no persistent "current node" — so a higher branch can always interrupt a lower one the moment its condition becomes true.

Parameters and ${param}

A program's params block declares named values. Anywhere else in the program, a string that is exactly ${name} — the whole string, not a substring inside a longer one — is replaced by that param's value at load time. A species' behavior.params may override a value for any param the program declares; it cannot introduce new params the program doesn't know about. A seasonal.phases[].behavior_params entry can further override params only while that phase is active.

Lint rules

The validator statically checks every program once for its own shape (with its declared defaults), then again for each species that uses it, with that species' behavior.params overrides substituted in:

Predicate vocabulary

Loading…

Action vocabulary

Shared programs