Behavior Tree
Behaviour tree is a mathematical model of plan execution used in computer science, robotics, control systems and video games.
Behavior trees describe switchings between a finite set of tasks in a modular fashion.
Their strength comes from their ability to create very complex tasks composed of simple tasks, without worrying how the simple tasks are implemented.
Behavior trees present some similarities to hierarchical state machines with the key difference that the main building block of a behavior is a task rather than a state

BehaviorTree.CPP is a flexible C++ library that can be used to create complex and flexible behavior trees. Website