$sequence
The $sequence
behaviour takes two or more children and, when executed, it executes each of its children in turn. If any child fails then $sequence
will stop at that point and fail. If all the children suceeed then the $sequence
will succeed.
The effect is like a boolean and
expression. Sequences are often a set of conditions followed by a set of actions.
Metaphorically a $sequence
is like a recipe, a set of steps that should be following from start to finish. If you get half way through a recipe and are missing a key ingredient, the recipe cannot be finished.
$select
The $select
behaviour takes two or more children and, when executed, it executes each of its children in turn. If any child succeeds then $select
will immediately succeed without executing any further children. If all the children fail then $select
will fail.
The effect is like a boolean or
expression. Selects often express a range of alternative behaviours where we want only the first to succeed.
Metaphorically a $select
is like the mains section of a menu, you pick an choose among the options available but don’t (at least the author tries not to) order two mains.
$select_p
The $select_p
behaviour is a variant on $select
. It takes a probability option p
and before executing any child will test p
. If the test succeeds it will execute that child and behaviour similar to $select
. If no children get executed or all the children fail then $select_p
will fail.
Options
|
1-100 |
probability of any given child getting executed |
$select_r
The $select_r
behaviour is a variant on $select
. When a $select_r
is executed it executes its children in a random order.
$loop
The $loop
behaviour takes one child and executes it a number of times specified by the option count
. If the child should fail then $loop
fails. If the child succeeds each time then $loop
succeeds.
Options
|
positive integer |
number of times to execute the child |
$loop_until
The $loop_until
behaviour takes one child and attempts to execute it a number of times specified by the option attempts
. If the child succeeds then $loop_until
succeeds. If the child never succeeds then $loop_until
fails.
Options
|
positive integer |
number of attempts to execute the child |
$maybe
The $maybe
behaviour takes one child and based on a probability option p
decides whether to attempt to execute it or not. If the p
test succeeds the child gets executed and $maybe
will succeed or fail based on whether the child succeeds or fails. If the p
test fails then $maybe
fails.
Options
|
1-100 |
probability of the child being executed |
$either
The $either
behaviour takes two children and based on the probability option p
decides whether to execute the first or the second child. If the p
test succeeds then the first child is executed, otherwise the second child is executed. $either
succeeds or fails based on whether the child it executes succeeds or fails.
Options
|
1-100 |
probability of the first child getting executed |
$random_choice
The $random_choice
behaviour takes at least two children and executes one child at
random. If the child succeeds then $random_choice
succeeds, otherwise it
fails.
$random_each
The $random_each
behaviour takes at least two children and executes one child at
random. $random_each
succeeds or fails based on the selected child succeeding
or failing.
Once a child has been executed it is not eligible to be selected again until
all the other children of $random_each
have, likewise, been executed. When all
the children have been executed $random_each
will begin again with a new
random order of children.
$invert
The $invert
behaviour takes one child and executes it. If the child succeeds then
$invert
fails, likewise if the child fails then $invert
will succeed.
$always
The $always
behaviour takes one child and executes it. It ignores whether the child
succeeds or fails and always suceeds itself.
$never
The $never
behaviour takes one child and executes it. It ignores whether the child
succeeds or fails, always failing itself. It’s a shorthand for
[$invert [$always …]]
.
$succeed
The $succeed
behaviour takes no chilren and when executed it always succeeds.
$fail
The $fail
behaviour takes no children and when executed it always fails.