Behavior Tree branches, leaves and tools.
Behavior Tree branches, leaves and tools.
(->dot node file-name)Eats node, saves tree to DOT file. (Uses spit -- Clojure only.)
Eats node, saves tree to DOT file. (Uses spit -- Clojure only.)
(->png node file-name)Eats node, saves tree to PNG. (Shells out to dot -- Clojure only.)
Eats node, saves tree to PNG. (Shells out to dot -- Clojure only.)
(->svg node file-name)Eats node, saves tree to SVG. (Shells out to dot -- Clojure only.)
Eats node, saves tree to SVG. (Shells out to dot -- Clojure only.)
(action seed)Create an Action node from given seed, which must at least contain :tick-fn.
Expectation regarding the tick-fn:
(tick-fn node) => node'
Create an Action node from given seed, which must at least
contain :tick-fn.
Expectation regarding the tick-fn:
(tick-fn node) => node'(as-parallel coll)Create a Parallel from collection of nodes.
Create a Parallel from collection of nodes.
(as-robin coll)Create a Robin from collection of nodes.
Create a Robin from collection of nodes.
(as-selector coll)Create a Selector from collection of nodes.
Create a Selector from collection of nodes.
(as-sequence coll)Create a Sequence from collection of nodes.
Create a Sequence from collection of nodes.
(attach-hook node hook-fn)(attach-hook node on-status hook-fn)Attach hook on SUCCESS, FAILURE, RUNNING, READY or :* key.
Hook function should have the signature:
(hook-fn node') => nil
Attach hook on SUCCESS, FAILURE, RUNNING, READY or :* key.
Hook function should have the signature:
(hook-fn node') => nil(condition seed)Create a Condition node from given seed, which must at least contain :pred-fn.
Expectation regarding the pred-fn:
(pred-fn node) => Boolean-ish
Create a Condition node from given seed, which must at least
contain :pred-fn.
Expectation regarding the pred-fn:
(pred-fn node) => Boolean-ish(decided? node)Is node shifted to SUCCESS, FAILURE or RUNNING?
Is node shifted to SUCCESS, FAILURE or RUNNING?
(decorate child)Decorate a child with default, pass-through Decorator.
Decorate a child with default, pass-through Decorator.
(decorator seed)Decorator is a hybrid node, defining both tick and part/join calls.
It holds a single child and decides if it should be executed: first tick is executed and calls:
(branch-pred decorator) => true | false
branch-pred returns true: child will be executed. Decorator changes its type to composite and signals Ready. During join child node is back and Decorator, it immediately runs post-join-fn:
(post-join-fn decorator) => decorator'
This function is fed Decorator containing ticked child, will decide final shape of the node. If post-join-fn is nil the decorator will just pass through flag and stash of the child.
branch-pred returns false: child is not used, own-tick-fn runs:
(own-tick-fn decorator) => decorator'
This constructor accepts a seed of:
By default Decorator will try to execute the child and pass its status up. If forced to tick default own-tick will just succeed.
Callable expectations, stash and stashless:
(branch-pred decorator) => true | false
(post-join-fn decorator) => Success | Failure | Running | Ready
(own-tick-fn decorator) => Success | Failure | Running | Ready
Decorator is a hybrid node, defining both tick and part/join calls.
It holds a single child and decides if it should be executed: first tick
is executed and calls:
(branch-pred decorator) => true | false
**branch-pred returns true:** child will be executed.
Decorator changes its type to composite and signals Ready. During join
child node is back and Decorator, it immediately runs post-join-fn:
(post-join-fn decorator) => decorator'
This function is fed Decorator containing ticked child, will decide final
shape of the node. If post-join-fn is nil the decorator will just pass
through flag and stash of the child.
**branch-pred returns false:** child is not used, own-tick-fn runs:
(own-tick-fn decorator) => decorator'
This constructor accepts a seed of:
* child, a node to be decorated,
* branch-pred used for branching? decision if first tick, defaut: yes,
* own-tick-fn used to tick on decorator if branch-pred returned false,
default: success,
* post-join-fn used to tick after join of finalized child, default: nil,
* flag preset, default: READY,
* properties for the node, default: nil,
* paramteres for the node, default: nil,
* stash for the node, default: nil.
By default Decorator will try to execute the child and pass its status
up. If forced to tick default own-tick will just succeed.
Callable expectations, stash and stashless:
(branch-pred decorator) => true | false
(post-join-fn decorator) => Success | Failure | Running | Ready
(own-tick-fn decorator) => Success | Failure | Running | Ready
(detach-hook node)(detach-hook node on-status)Detach hook on SUCCESS, FAILURE, RUNNING, READY or :* key.
Detach hook on SUCCESS, FAILURE, RUNNING, READY or :* key.
(done? node)Is node shifted to SUCCESS or FAILURE?
Is node shifted to SUCCESS or FAILURE?
(dot-string node)Eats node, returns DOT graph string.
Walks the tree Depth-First, numbers nodes and links them.
Eats node, returns DOT graph string. Walks the tree Depth-First, numbers nodes and links them.
(failure node)(failure node stash)Shift node to FAILURE. Optionally with stash.
Shift node to FAILURE. Optionally with stash.
Predefined Action that will fail on tick.
Predefined Action that will fail on tick.
(fn->action tick-fn)(fn->action name tick-fn)Create Action out of a tick-fn function.
Create Action out of a tick-fn function.
(fn->condition pred-fn)(fn->condition name pred-fn)Create Condition out of a pred-fn function.
Create Condition out of a pred-fn function.
(mu & _)Always nil, just like (constantly nil), except interned.
Always nil, just like (constantly nil), except interned.
(no & _)Always false, just like (constantly false), except interned.
Always false, just like (constantly false), except interned.
Branching and ticking, access and viz helpers, just node things.
Branching and ticking, access and viz helpers, just node things.
(-node? _)Is this a Node?
Is this a Node?
(dot-color this)Node color in the visualization.
Node color in the visualization.
(dot-shape this)Desired Shape in the visualization.
Desired Shape in the visualization.
(join this child*)Join current child.
Join current child.
(shift this)(shift this flag*)Get-set flag.
Get-set flag.
(tick this)Update node.
Update node.
(branch? this)Is this a branch?
Is this a branch?
(yield this)(yield this yield*)Get-set stash.
Get-set stash.
(hooks this)(hooks this hook*)Get-set hooks.
Get-set hooks.
(part this)Get next child.
Get next child.
(params this)(params this params*)Get-set parameters.
Get-set parameters.
(branches this)(branches this children*)Get-set children.
Get-set children.
(label this)(label this label*)Get-set name.
Get-set name.
(stem this)(stem this stem*)Get-set node.
Get-set node.
(dot-label this)Node Description in the visualization.
Node Description in the visualization.
(parallel seed)Create a Parallel node with given seed and nodes. Children will run in order, child that is RUNNING will be put in queue and Parallel will get READY to execute next child immediately. Parallel will itself return RUNNING on retry and full cycle, which can be changed.
When all children are either SUCCESS or FAILURE final tally will executes. If no threshold is reached, then fresh copy of children will be brought back for execution and Parallel will raise retry count and retry.
Parallel will evalute to, in order:
If both success-th and failure-th were reached SUCCESS will be returned.
The rewind-fn is given Parallel to prepare it for re-run, defaults to nil, in which case fresh copy of children is used. The rewind-fn can overwrite retry-flag, which is set before that function runs.
For alternate Parallel implementation see: Robin.
Create a Parallel node with given seed and nodes. Children will run in order, child that is RUNNING will be put in queue and Parallel will get READY to execute next child immediately. Parallel will itself return RUNNING on retry and full cycle, which can be changed. When all children are either SUCCESS or FAILURE final tally will executes. If no threshold is reached, then fresh copy of children will be brought back for execution and Parallel will raise retry count and retry. Parallel will evalute to, in order: * SUCCESS if all children are done and success-th was reached * FAILURE if all children are done and failure-th was reached * cycle-flag on cycle completion (all children ran once) * retry-flag on retry initiation. If both success-th and failure-th were reached SUCCESS will be returned. The rewind-fn is given Parallel to prepare it for re-run, defaults to nil, in which case fresh copy of children is used. The rewind-fn can overwrite retry-flag, which is set before that function runs. For alternate Parallel implementation see: Robin.
(parallel* & nodes)Create a Parallel from node arguments.
Create a Parallel from node arguments.
(print-callstack a-root)Print callstack from given a Stepper implementing callstack.
Print callstack from given a Stepper implementing callstack.
(print-tree start-node)(print-tree marker-pred start-node)Print nodes of a tree, indented by depth, marked via predicate.
Print nodes of a tree, indented by depth, marked via predicate.
(ready node)(ready node stash)Shift node to READY. Optionally with stash.
Shift node to READY. Optionally with stash.
(robin seed)Create a Robin node with given seed and nodes. Children will run in order, child that is RUNNING will be put in queue and Robin will get READY to execute next child immediately. Robin will be RUNNING on retry and cycle completion which can be customized.
When all children are either SUCCESS or FAILURE summary-fn will execute on Robin. If it returns SUCCESS or FAILURE then Robin ends its run with that. If it returns RUNNING Robin will retry.
Robin will evalute to:
If no summary-fn is provided Robin returns SUCCESS once all children are done.
The rewind-fn is given Robin to prepare it for re-run, defaults to nil, in which case fresh copy of children is used. The rewind-fn is able to overwrite retry-flag, because that is set before it runs.
Robin is a non-canon Parallel implementation.
Create a Robin node with given seed and nodes. Children will run in order, child that is RUNNING will be put in queue and Robin will get READY to execute next child immediately. Robin will be RUNNING on retry and cycle completion which can be customized. When all children are either SUCCESS or FAILURE summary-fn will execute on Robin. If it returns SUCCESS or FAILURE then Robin ends its run with that. If it returns RUNNING Robin will retry. Robin will evalute to: * SUCCESS if all children are done and summary-fn sets SUCCESS * FAILURE if all children are done and summary-fn sets FAILURE * cycle-flag on cycle completion (all children ran once) * retry-flag on retry initiation. If no summary-fn is provided Robin returns SUCCESS once all children are done. The rewind-fn is given Robin to prepare it for re-run, defaults to nil, in which case fresh copy of children is used. The rewind-fn is able to overwrite retry-flag, because that is set before it runs. Robin is a non-canon Parallel implementation.
(robin* & nodes)Create a Robin from node arguments.
Create a Robin from node arguments.
(root seed)Create Root node with given seed and tree.
Create Root node with given seed and tree.
(root-of tree)Create Root node with given tree node.
Create Root node with given tree node.
(run-hooks! node)Try to execute hooks for side-effects, return node.
Try to execute hooks for side-effects, return node.
(running node)(running node stash)Shift node to RUNNING. Optionally with stash.
Shift node to RUNNING. Optionally with stash.
Predefined Action that will be running on tick.
Predefined Action that will be running on tick.
(selector seed)Create a Selector node from given seed, which must at least contain :children.
Sequence will evalute to:
Create a Selector node from given seed, which must at least contain :children. Sequence will evalute to: * SUCCESS if a child returns SUCCESS. * FAILURE if all children ran and resulted in FAILURE. * RUNNING immediately if any child is RUNNING.
(selector* & nodes)Create a Selector from node arguments.
Create a Selector from node arguments.
(sequence seed)Create a Sequence node from given seed which must at least contain :children.
Sequence will evalute to:
Create a Sequence node from given seed which must at least contain :children. Sequence will evalute to: * SUCCESS if all children ran and were SUCCESS. * FAILURE immediately if any child is FAILURE. * RUNNING immediately if any child is RUNNING.
(sequence* & nodes)Create a Sequence from node arguments.
Create a Sequence from node arguments.
Step-by-step ticking.
Step-by-step ticking.
(-stepper? this)Is this a Stepper?
Is this a Stepper?
(callstack this)Return full stack from root to current node.
Return full stack from root to current node.
(exhaust this)Step through tree until finished.
Step through tree until finished.
(finished? this)Is this tick completed?.
Is this tick completed?.
(handle-branch this)Perform branch op.
Perform branch op.
(handle-leaf this)Perform leaf op.
Perform leaf op.
(step this)Perform single op.
Perform single op.
(step-until this pred)Perform steps until predicate is true.
Perform steps until predicate is true.
(success node)(success node stash)Shift node to SUCCESS. Optionally with stash.
Shift node to SUCCESS. Optionally with stash.
Predefined Action that will succeed on tick.
Predefined Action that will succeed on tick.
Predefined succeeding condition.
Predefined succeeding condition.
(to-failure a-fn)Create an Action that runs given function on stash and fails.
Create an Action that runs given function on stash and fails.
(to-success a-fn)Create an Action that runs given function on stash and succeeds.
Create an Action that runs given function on stash and succeeds.
(via-pred pred)Create a Condition that runs given predicate on stash.
Create a Condition that runs given predicate on stash.
(yes & _)Always true, just like (constantly true), except interned.
Always true, just like (constantly true), except interned.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |