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

Types

Actions must return one of these outcomes.

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

Link to this type

outcome() View Source
outcome() ::
  :succeed
  | :fail
  | :continue
  | :done
  | {:error, any()}
  | {:succeed, keyword()}
  | {:fail, keyword()}
  | {:continue, keyword()}

Actions must return one of these outcomes.

Link to this section Functions

Link to this function

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)
])

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.

Link to this function

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.

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