Defines an action tree. Action trees are comprised of a trigger and a tree of actions.
Exception thrown when an action tree is malformed or cannot be parsed.
Defines an ActionTree for the Geneva system.
Creates this action tree.
- direction (str) – Direction this tree is facing (“out”, “in”)
- trigger (
actions.trigger.Trigger) – Trigger to use with this tree
Adds an action to this action tree.
Checks if this action tree should run on this packet.
Picks a random element in the tree.
Checks if an action is contained in the tree.
Counts the number of leaves.
do_parse(node, string, logger)¶
Handles the preorder recursive parsing.
do_run(node, packet, logger)¶
Handles recursively running a packet down the tree.
Returns the parent of the given node and direction of the child.
get_rand_action(direction, request=None, allow_terminal=True, disabled=None)¶
Retrieves and initializes a random action that can run in the given direction.
Returns the number of locations a new action could be added.
initialize(num_actions, environment_id, allow_terminal=True, disabled=None)¶
Sets up this action tree with a given number of random actions. Note that the returned action trees may have less actions than num_actions if terminal actions are used.
Mates this tree with another tree.
Mutates this action tree with respect to a given direction.
Parses a string representation of an action tree into this object.
Yields a preorder traversal of the tree.
Pretty prints the tree.
pretty_print_help(root, visual=False, parent=None)¶
- Pretty prints the tree.
- root is the highest-level node you wish to start printing
- [visual] controls whether a png should be created, by default, this is false.
- [parent] is an optional parameter specifying the parent of a given node, should only be used by this function.
Returns the root with its children as an anytree node.
Removes a given action from the tree.
Removes a random leaf from the tree.
Runs a packet through the action tree.
Yields a preorder traversal of the tree to create a string representation.
swap(my_donation, other_tree, other_donation)¶
Swaps a node in this tree with a node in another tree.