Skip to content

Things that decide for themselves

orblit_agent has two layers. They often get mixed together, and they are better kept apart.

Steering answers where to go: a force, worked out from the world, that moves something this frame. Seek, flee, arrive, wander, separate, align, cohere, pursue, evade.

Behaviour trees answer what to want: which of those to run, and when to stop.

Take an agent that runs away when it is frightened and wanders the rest of the time. That is a behaviour tree picking between two steering behaviours. Build it as one thing and you get a state machine, and you have to rewrite it every time you add a state.

Behaviours return forces, and forces add. That is the whole model. It is why a flock is separate + align + cohere with weights, and not a flocking algorithm.

Sequences, selectors, decorators and leaves: the standard vocabulary. A tick returns running, succeeded or failed, and a node that was running on the last tick is resumed rather than restarted.

Unlike the sampled parts of the engine, a behaviour tree really does step. A decision made last tick is meant to stick, and that is history rather than a value at a time. See sampled, not stepped for where the line falls.

Steering needs to know about neighbours, and asking every agent about every other agent is quadratic. orblit_collide gives you the spatial hash for it.