asasine/BehaviorTree.NET

Add `ControlWithMemory` nodes

asasine opened this issue · 0 comments

Behavior trees differentiate between control nodes and control nodes with memory. The two behave differently when ticked again after a child returns RUNNING.

A control node should restart from its first child after a child returns RUNNING. A control node with memory should remember which child returned RUNNING and tick from that point, not ticking any previous children.

The current implementation of Sequence is technically SequenceWithMemory, as it remembers which child was ticked if the child returns RUNNING and ticks that child again, not ticking any of its previous children. The current implementation of Fallback is not with memory, as it restarts from the first child, even after a child returns RUNNING.

One key feature of a control node without is the halting behavior when a child returns RUNNING. When a child i returns RUNNING, a control node without memory should halt all children in the range [i + 1, previous_running_child_index]. As an example, let's have a Sequence with three children, and the first propagated ticked results in child statuses [SUCCESS, SUCCESS, RUNNING]. If the second propagated tick results in the first child returning RUNNING, the second and third children should be halted. A Fallback should behave similarly, halting when a child i < previous_running_child_index returns FAILURE.