skip to content

In a behavior tree, what does the running status mean, and how does the tree resume a running action on the next tick?

level: middleimportance: must knowfreq 62%

answer

  1. work spans several ticks
  2. the action keeps its own progress
  3. composites with and without memory
  4. halt whatever gets preempted

basics

~20 s

Running means an action has started but needs more ticks. Next tick, a reactive tree re-checks earlier children before reaching the action again, while a composite with memory skips straight to it; a preempted action must be halted.

solid answer

~50 s

`running` says an action such as "reload" has started and is not finished; it propagates to the root and that tick ends. On the next tick there are two common resumption rules. **Memoryless (reactive) composites** walk from their first child again, so conditions such as "magazine empty?" or a higher-priority branch are re-checked before the traversal reaches the same action, which continues rather than restarts because it keeps its own progress. **Composites with memory** remember the index of the running child and tick it directly, skipping siblings that already succeeded. That is cheaper and avoids repeating one-shot steps, but it will not notice that an earlier condition has become false. Whichever rule is used, an action that was running and is not reached on this tick has been preempted and must be **halted**, so it can stop its animation and release anything it holds.

code

pseudocode · 7 lines
pseudocode
function tickReactiveSequence(node):
    for i from 0 to count(node.children) - 1:
        status = tick(node.children[i])
        if status != SUCCESS:
            haltRunningChildrenAfter(node, i)
            return status
    return SUCCESS

go deeper

for a junior

Recall that running means started but not finished, that it passes up to the root, and that the game keeps going while the action continues on later ticks.

for a middle

Explain both resumption rules, memoryless and with memory, what each re-checks on the next tick, and why an action must keep its own progress and offer a halt hook.

for a senior

Diagnose restart loops, zombie actions and stale plans from their symptoms, and justify where in a tree you use memory and where you need reactivity.

for a principal

Decide the team's convention for composites and the halt contract every action must honour, since mixed conventions make trees impossible to read across designers.

## What running means Behavior-tree nodes return one of three statuses each tick: `success`, `failure` or `running`. **Running** belongs to actions that take time, such as a two-second reload, a walk to a cover point, or a wait. The action starts, reports running, and the status travels up the tree: a sequence that receives running returns running, a selector that receives running returns running, and the tick ends at the root. Nothing blocks; the game carries on, and the tree is ticked again later. Two consequences follow: - The action must keep its own **progress** between ticks, for example a "started" flag and a timer, so that the second tick continues the reload instead of starting it again. - The tree must decide, on the next tick, **how to get back** to that action and whether it should still be running at all. ## Rule one: re-walk from the root with memoryless composites The simplest rule ticks the tree from the root every time, with **memoryless** (also called reactive) composites that always start at their first child: 1. The root selector re-checks its higher-priority branches first. 2. Inside the active sequence, the leading conditions are re-checked. 3. If everything still holds, the walk arrives at the same running action, which continues. This is what makes a tree **reactive**: a higher-priority branch, or a condition that has become false, takes over on the very next tick. The price is that every tick re-evaluates many nodes, and any action placed before the running one in a sequence is ticked again too, which is a problem if that action is not idempotent. ## Rule two: composites with memory A composite **with memory** remembers which child was running and ticks it directly next time, skipping siblings that already succeeded. It resets that memory when it finishes with success or failure, or is halted. ```pseudocode function tickSequenceWithMemory(node): for i from node.current to count(node.children) - 1: status = tick(node.children[i]) if status == RUNNING: node.current = i return RUNNING if status == FAILURE: node.current = 0 return FAILURE node.current = 0 return SUCCESS ``` This suits step-by-step tasks such as "crouch, then reload, then call out", where re-running "crouch" each tick would be wrong. It also means the sequence stops watching its own guard: once "magazine empty?" has succeeded and "reload" is running, the guard is not asked again until the sequence finishes. | rule | next tick starts at | notices a changed condition | cost and risk | |---|---|---|---| | memoryless (reactive) | the first child | yes, on the next tick | re-evaluates more nodes; earlier actions re-tick | | with memory | the running child | not inside it; only a reactive parent or an abort can | cheaper; can keep running a stale plan | Many trees mix the two: a reactive selector near the root for priorities, sequences with memory for the steps of a task. Some engines go further and make the tree event-driven, ticking only the running nodes and re-evaluating when data changes; that design needs explicit aborts, which are a topic of their own. ## Halting a preempted action Under either rule an action can be **preempted**: it was running last tick, and this tick the traversal did not reach it because a higher-priority branch took over or a reactive guard failed. Nothing in the status flow tells the action that it has lost; the tree has to call a **halt** (or abort) hook on it. A good halt hook: - stops the animation or movement the action started; - releases anything it reserved, such as a claimed cover point; - leaves shared data consistent, for example deciding whether a partly finished reload refills the magazine; - resets the action's progress so its next start is clean. ## Everyday defects - **An action restarts every tick.** It does not keep its own progress, or an earlier non-idempotent action in a reactive sequence re-triggers it. The reload animation begins again each frame and never ends. - **A zombie action.** A preempted action was never halted, so the reload animation keeps playing while the soldier runs to cover. - **A stale plan.** A sequence with memory keeps reloading after its guard has stopped holding, because it never re-checks the guard. - **Running treated as failure.** A custom composite mishandles running and falls through to the next option while the first is still working.

  • Why should an action not restart when it is ticked a second time while running?
    Because ticks are frequent, a reload restarted each tick never finishes. The action keeps its own progress, typically a started flag and a timer, runs its start logic only on the first tick and its update logic afterwards, and resets when it finishes or is halted.
  • Why can a sequence with memory make an NPC look unresponsive?
    It ticks the running child directly and does not re-check earlier children, including its guard condition. If the reason for the task disappears mid-way, the sequence keeps running until the child ends. A reactive composite above it, or an explicit abort, is needed to notice the change.

  • Running means the action failed and will be retried next tick.
  • The tree blocks inside a running action until it completes.
  • A preempted action stops by itself because it is no longer ticked.
  • A sequence with memory still re-checks its guard condition on every tick.
  • An action may restart from scratch on every tick, since the tree ticks it again anyway.