# Types

  • Reactive: pre-planned conditional actions, responds to env. state, most games are reactive. E.g. Decision Trees
  • Deliberative: models env., inferences made to determine the plan to achieve goal
  • Reflective: learn from experience

# Rule-based systems

# Production Rules

  • Define actions to be executed in response to conditions
  • Simple architecture but difficult to organize as there is not a straightforward ordering of rules

rule-based-systems.png

# RBS Dynamic Priority

rbs-dynamic-priority.png

# Advanced RBS

  • RBSs can get much more advanced
  • Expanded features enable robust response to conditions
  • These RBSs tend to be more resource intensive

# Behavior Trees

  • A reactive decision making system that shares some aspects of state machines
  • But has a more declarative structure and enforces an understandable structure
  • There are three kinds of nodes
    • Composite
    • Decorator
    • Leaf
  • And at any given time, the nodes can be in three possible states
    • Success
    • Failure
    • Running

behavior-tree-nodes.png

  • Transitions are externalized from states. Instead what you normally think of states in a FSM become behaviors. This allows easy reuse of behaviors as context-specific transitions are decoupled.
  • Easy for non-programmers to create (usually with visual tools or high level script)
  • Composable, self contained and easy to alter and reuse
  • Fails gracefully

# Composite Node

  • One or more children
  • Sequence (AND), Selector (OR), or Random
  • Short circuiting of Boolean logic
  • Returns success or fail (based on children returns typically)
  • Outcome of a lot of children (like leaf nodes) get bubbled up and lead to the outcome of the the composite node

# Decorate Node

  • One child
  • Works by changing or filtering the return of a child
  • Examples:
    • Inverter (like NOT)
    • Succeeder (always true, runs child but doesn't care about success/failure)
    • Repeater (like keep shooting)
    • Repeat until fail

# Leaf Node

  • As part of Behavior Tree API, you often find implementation of these terminal nodes. They are the behaviors.
  • Returns success, fail or processing
  • For example, Init() is called on first visit, Process() is called until complete afterwards.

# One action per tick

  • Each node keeps track of current child to execute
  • At start of Update(), walk the tree to find our current node. If the BT executed it last frame, then continue, otherwise, reset it.
  • Nodes return success, fail or processing

# An Example

behavior-tree-example.png

# Non-deterministic nature

  • Strict oder == predictable
  • Introduce random selector or sequence nodes
  • Can also introduce prioritized versions which select or sequence according to world state (can be less predictable but more efficient)

# Semaphores & Blackboards

behavior-tree-semaphores.png

behavior-tree-blackboards.png