Expand description

Decision makers are engines that usually contain states and decide under what circumstances switch into which state.

Engines

  • Machinery - Finite State Machine (or simply network of states connected by conditions to met for jumps to happen).
  • Reasoner - Utility AI agent (that scores each state and selects one with the highest score).
  • Planner - Goal Oriented Action Planning agent (finds the best path through all possible actions for goal selected by another decision maker assigned into this planner).
  • Sequencer - Goes through states (ones that are possible to run) in a sequence.
  • Selector - Selects only one state from list of possible states to run.
  • Parallelizer - Runs all states (that are possible to run) at the same time.

Modularity and hierarchical composition

The main goal of this crate is to provide a way to construct modern AI solutions by combining smaller decision making engines.

Let me show some examples to clarify how this modularity helps building more complex AI:

HFSM

See: https://cps-vo.org/group/hfsm

One common AI technique is HFSM (Hierarchical Finite State Machine) used to optimize FSM networks (number of connections) by grouping sub-networks into clusters of states and connect these clusters. Imagine you have states such as: [Eat, Sleep, Work, Drive].

Instead of connecting each one with every other states like this:

  • Eat
  • Sleep
  • Work
  • Drive

you group them into hierarchy of two levels with and connect only states that are on the same level of hierarchy. This produces two levels of hierarchy and reduces number of connections between them:

  • Home:
    • Eat
    • Sleep
  • Workplace:
    • Eat
    • Work
  • Drive

Behavior Tree

See: https://en.wikipedia.org/wiki/Behavior_tree_(artificial_intelligence,_robotics_and_control)

Another commonly used AI technique is Behavior Tree that evaluates tree nodes from the top left to the bottom right as long as nodes succeeds. To make behavior trees possible with this crate, you can just combine Sequencer, Selector and Task manually in a tree, or use BehaviorTree builder to easily define a tree and let builder produce properly setup tree of decision makers:

  • Selector:
    • Drive
    • Sequence (Home):
      • Sleep
      • Eat
    • Sequence (Workplace):
      • Work
      • Eat

Modules

  • Machinery (a.k.a. Finite State Machine) decision maker.
  • Run states in parallel.
  • Planner (a.k.a. Goal Oriented Action Planner) decision maker.
  • Reasoner (a.k.a. Utility) decision maker.
  • Runs first state that succeeds (boolean OR operation).
  • Run states one-by-one as long as they succeed (boolean AND operation).

Structs

Traits