ABSTRACT

In artificial intelligence development, a common problem to solve is behavior selection. There are many solutions to this problem, such as finite-state machines, behavior trees, utility-based selection, neural networks, and planners. This chapter explores the nuances of a type of planner called hierarchical task networks (HTN) by using real world examples that one can run into during development. There are two types of tasks that are used to build a HTN, called compound tasks and primitive tasks. Primitive tasks represent a single step that can be performed by nonplayable character (NPC). In Trunk Thumper example, uprooting a tree or attacking with a trunk slam would be examples of primitive tasks. A set of primitive tasks is the plan that we are ultimately getting out of the HTN. Compound tasks are where HTN get their “hierarchical” nature. Running an HTN plan is pretty straightforward. The NPC’s plan runner will attempt to execute each primitive task’s operator in sequence.