The :always-failure node has no specific parameter. It ticks its child and responds to the result in this way :
The :always-failure node has no specific parameter. It ticks its child and responds to the result in this way : - Child is :running -> always-failure is :running - Child is :success -> always-failure is :failure - Child is :failure -> alway-failure is :failure
The :always-success node has no specific parameter. It ticks its child and responds to the result in this way :
The :always-success node has no specific parameter. It ticks its child and responds to the result in this way : - Child is :running -> always-success is :running - Child is :success -> always-success is :success - Child is :failure -> alway-success is :success
The :bind node establishes a dynamic context, storing some data in the defined variables while it executes its child subtree.
It has a single parameter :let which, just like clojure's let is a vector of variable names (a keyword) and variable values (a value or a context funtion).
[:bind {:let [:one 1
:two (bt/bb-getter-in [:some-bb-key])]}
[send-event {:event :hello :arg (bt/var-getter :two)}]]
The :bind node establishes a dynamic context, storing some data in the defined variables while it executes its child subtree. It has a single parameter :let which, just like clojure's let is a vector of variable names (a keyword) and variable values (a value or a context funtion). ```clojure [:bind {:let [:one 1 :two (bt/bb-getter-in [:some-bb-key])]} [send-event {:event :hello :arg (bt/var-getter :two)}]] ```
The :consume-event node consumes an event if it is found in the inbound event list. -If the event was found, the node succeeds. -If the event was not found, the node fails, or stays running if the :wait? parameter is true.
Parameters:
The :consume-event node consumes an event if it is found in the inbound event list. -If the event was found, the node succeeds. -If the event was not found, the node fails, or stays running if the :wait? parameter is true. Parameters: - :event : A keyword, or keyword returning context function. The name of the event to be consumed. - :pick? : A context function with two parameters. first the tree context, then the event argument being considered. This acts as an additional filter when considering incoming events to be consumed. The event will be consumed if this function returns a truthy value. - :wait? : A boolean, or boolean returning context function. When true the node will stay :running until the event is consumed. - :with-arg : A context function with two parameters, first the tree context, then the consumed event argument. This must return a possibly updated tree context.
The :failure-leaf is a simple node that always fails
The :failure-leaf is a simple node that always fails
The :guard node is a special kind of branch node that can only have two children. The first child is called the predicate node, the second child is the payload node.
It is usefull for possibly interrupting a running subtree based on the predicate result.
Each time the :guard node is executed, that is when it is :fresh or :running, the predicate node will be re-run (refreshing it if it was in a :success or :failure state)
The predicate node must succeed or fail in a single tick.
The :guard node is a special kind of branch node that can only have two children. The first child is called the predicate node, the second child is the payload node. It is usefull for possibly interrupting a running subtree based on the predicate result. Each time the :guard node is executed, that is when it is :fresh or :running, the predicate node will be re-run (refreshing it if it was in a :success or :failure state) - If the predicate succeeds, the payload node is then executed, and its result state assigned to the :guard node. - If the predicate fails, the payload node is not executed, or is interrupted when running, and the :guard node is set as :failure. The predicate node must succeed or fail in a single tick.
The :guard-selector node may only have :guard children. Each time it is run, it will refresh and check each of its children's predicates until it finds one that succeeds. It will then run the child's payload, possibly interrupting any other previously running child payload.
The :guard-selector node will succeed when any of its children succeeds, and fail when either the running child fails, or all the predicates fail.
The :guard-selector node may only have :guard children. Each time it is run, it will refresh and check each of its children's predicates until it finds one that succeeds. It will then run the child's payload, possibly interrupting any other previously running child payload. The :guard-selector node will succeed when any of its children succeeds, and fail when either the running child fails, or all the predicates fail.
The :inverter node succeeds when its child fails, and fails when its child succeeds.
The :inverter node succeeds when its child fails, and fails when its child succeeds.
The :map node loops over a sequence, re-running its child with each item of the sequence being bound to a var. parameters:
When the child succeeds :
The sequence content is determined when the :map node is :fresh
The :map node loops over a sequence, re-running its child with each item of the sequence being bound to a var. parameters: - :seq : a sequence, or sequence returning context function - :bind-item : the keyword name of the var to which each item will be bound When the child succeeds : - if there are more items in the sequence, the child will be refreshed and rerun with the next item being bound. - if there are no more items, the :map node will succeed When the child fails, the :map node will fail The sequence content is determined when the :map node is :fresh
The :on-cancel node has exactly two children. The first one is the cancel node and the second one is the payload node. It executes its payload node in a transparent manner. If the node is cancelled, that is when it goes from the :running state to the :fresh state, the cancel node is then executed.
Please note that the cancel node must succeed or fail in a single behavior tree tick.
This node is particularly usefull for releasing previously aquired resources, like a network socket for instance.
[:on-cancel [:send-event {:event :release-the-socket}]
use-socket-sub-tree]
The :on-cancel node has exactly two children. The first one is the cancel node and the second one is the payload node. It executes its payload node in a transparent manner. If the node is cancelled, that is when it goes from the :running state to the :fresh state, the cancel node is then executed. Please note that the cancel node must succeed or fail in a single behavior tree tick. This node is particularly usefull for releasing previously aquired resources, like a network socket for instance. ```clojure [:on-cancel [:send-event {:event :release-the-socket}] use-socket-sub-tree] ```
The :on-event node acts in the same way as the :consume-event node, but it binds the event argument to a var and execute its child.
Parameters:
The :on-event node acts in the same way as the :consume-event node, but it binds the event argument to a var and execute its child. Parameters: - :event : A keyword, or keyword returning context function. The name of the event to be consumed. - :pick? : A context function with two parameters. first the tree context, then the event argument being considered. This acts as an additional filter when considering incoming events to be consumed. The event will be consumed if this function returns a truthy value. - :wait? : A boolean, or boolean returning context function. When true the node will stay :running until the event is consumed. - :bind-arg : the keyword name of the var to which the event argument will be bound.
The :parallel node executes its children in parallel, until it succeeds or fails according to its policy parameter.
parameters :
Every child node is run before their result is checked against the policy
The :parallel node executes its children in parallel, until it succeeds or fails according to its policy parameter. parameters : - :rerun-children : (default to false) The :success and :failure children are refreshed and rerun while this node is :running - :policy : (defaults to :sequence) the policy can be : - :sequence : the node will succeed when all children succeed, fail when any fails - :select : the node will succeed when any child succeeds, fail when all fail - a map of the form {:success <value> :failure <value>} : each value can be - :every : every node must have the :success or :failure status - :some : some node must have the :success or :failure status - an integer : the specified number of children must have this status Every child node is run before their result is checked against the policy
The :predicate node succeeds or fail depending on its pred parameter. parameters:
The :predicate node succeeds or fail depending on its pred parameter. parameters: - :func : This context function will extract data from the tree context, before passing it to the :pred function. - :pred : (defaults to identity) This function will be passed the result of the :func call. The node will succeed if this returns a truthy value, fail otherwise. - :wait? : The node will stay in the :running state until the predicate is met.
The :repeat node will refresh and repeat its child. parameters :
The :repeat node will refresh and repeat its child. parameters : - :count : An integer, or integer returning context function. Once the count is reached, that is when the child succeeded or failed "count" times, the node succeeds. - :while : A predicate context function that is called on each iteration, the node succeeds as soon as this returns a falsy value
The :select node succeeds when any of its children succeeds, and fails when every child fails
The :select node succeeds when any of its children succeeds, and fails when every child fails
The :send-event node sends an event to the outside world. It may later be picked buy their core/get-events function.
parameters:
The :send-event node sends an event to the outside world. It may later be picked buy their core/get-events function. parameters: - :event : a keyword or keyword returning function. The event name. - :arg : an optional function returning the for this event
The :sequence function succeeds when all its children succeed and fails when any of these fails.
The :sequence function succeeds when all its children succeed and fails when any of these fails.
The :success-leaf always succeeds
The :success-leaf always succeeds
The :tick-eater node stays :running for a number of ticks, and then succeeds. parameters:
The :tick-eater node stays :running for a number of ticks, and then succeeds. parameters: - :count : An integer, or integer returning function. The number of ticks before succeeding.
The :timer node stays :running until a certain duration (in milliseconds) has elapsed. parameters:
This node has two modes of operation.
Although they're not always necessary, named timers are the most precise as their combined durations do not depend on the tick invokation times.
The :timer node stays :running until a certain duration (in milliseconds) has elapsed. parameters: - :timer : an optional keyword or keyword returning context function. The name of this timer. - :duration : an integer or integer returning context function. The numebr of milliseconds this node stays :running before succeeding. This node has two modes of operation. - named timer : when the :timer parameter is set, the :timer node will start counting time based on the last completed timer with the same name (or now if none were found) - free timer : The duration starts counting when the :timer node passes from :fresh to :running Although they're not always necessary, named timers are the most precise as their combined durations do not depend on the tick invokation times.
The :trace node helps in debugging behavior trees. It will activate tracing on its sub-tree, sending hierarchical logging to the tap.
The :trace node helps in debugging behavior trees. It will activate tracing on its sub-tree, sending hierarchical logging to the tap.
The :until-failure node refreshes and reruns its child node until it fails, and then returns :success
The :until-failure node refreshes and reruns its child node until it fails, and then returns :success
The :until-success node refreshes and reruns its child node until it succeeds, and then returns :success
The :until-success node refreshes and reruns its child node until it succeeds, and then returns :success
The :update node updates the tree context and then succeeds. parameters :
The :update node updates the tree context and then succeeds. parameters : - :func : a context function that updates the tree context is being passed.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close