HTN Demo


Basic implementation of a Hierarchical Task Network (HTN) in the form of a Unity minigame.


The player plays against an AI-controlled Agent and controls the Blue circle, collecting the rotating items in the alcoves on the edge of the screen, while avoiding the patrolling enemy AI. The goal is to collect the most items while avoiding getting caught. Both players possess a Teleport Trap holding 2 uses, which can be used by pressing the ‘Space’ key. Doing so will teleport the closest enemy/agent


The opposing Agent is controlled by a basic Hierarchical Task Network. Implementation was based off of this section in Game AI Pro. The implemented pseudocode described in the paper can be found in the EnemyAgentPlanner class in the MakePlan() method.

The Enemy Agent AI has a HTN Domain as follows:

HTN Domain