bot_army v1.0.0 BotArmy.Actions View Source
Generic Actions.
Actions are functions that take the bot's context and any supplied arguments, perform some useful side effects, and then return the outcome. The context is always passed as the first argument.
Valid outcomes are: :succeed
, :fail
, :continue
, :done
or {:error, reason}
.
:succeed
, :fail
, and :continue
can also be in the form of {:succeed, key: "value"}
if you want save/update the context.
Link to this section Summary
Functions
A semantic helper to define actions in your behavior tree.
This will stop the bot from running (by default bots "loop" continously through their behavior trees
Signal that this bot has errored, causing the bot's process to die with the given reason.
A helpful way to "tap" the flow of the behavior tree for debugging.
Given a rate as a percentage, this will succeed that percent of the time, and fail otherwise.
Makes the calling process wait for the given number of seconds
Makes the calling process wait for a random number of seconds in the range defined by the given integers min and max
Link to this section Types
outcome() View Source
Actions must return one of these outcomes.
Link to this section Functions
action(module, fun, args \\ []) View Source
A semantic helper to define actions in your behavior tree.
Node.sequence([
...
action(BotArmy.Actions, :wait, [5]),
...
action(BotArmy.Actions, :done)
])
done(_) View Source
This will stop the bot from running (by default bots "loop" continously through their behavior trees
error(_, reason) View Source
Signal that this bot has errored, causing the bot's process to die with the given reason.
log(context, message) View Source
A helpful way to "tap" the flow of the behavior tree for debugging.
succeed_rate(context, rate) View Source
Given a rate as a percentage, this will succeed that percent of the time, and fail otherwise.
For example succeed_rate(context, 0.25)
will succeed on average 1 our of 4 tries.
wait(context, s \\ 5) View Source
Makes the calling process wait for the given number of seconds
wait(context, min, max) View Source
Makes the calling process wait for a random number of seconds in the range defined by the given integers min and max