Automated Planning and HTNs Planning – A brief intro Classical Planning – The STRIPS Language HTN – Hierarchical Task Networks & SHOP2 What is planning? Planning is the process of generating a sequence of actions that will achieve a goal. Automated planning is a branch of computer science that deals with producing plans to achieve a goal. Features of a planning system A representation of the state of the world. A representation of the goals to be achieved. Actions that change the state of the world. The Blocks World Example The world (problem domain) is a table covered by children’s blocks. Blocks can sit on the table on on each other. We want to move blocks from one configuration to another. The STRIPS Planning Language STanford Research Institute Problem Solver Based on First Order Predicate Calculus. Developed in 1971 STRIPS State Representation Conjunctions of state symbols. But not disjunctions or negative assertions InHouse & HasDinner Conjunctions of grounded operators. At(Mark, House) & Using(Jane, Computer) STRIPS Goals A partially specified state At(Joe, Museum) & Has(Joe, Camera) STRIPS Actions Operators are actions that transform world state Parameters – Walk( person, place1, place2 ) Precondition – Conjunctions describing partial states. At( person, place1 ) & Door( place1, open ) Effects – Conjunctions and negations to add and delete state members. ~At( person, place1 ) & At( person, place2 ) Constants and Predicates Operators (Actions) The Algorithm Planning is a search procedure. A graph of a search space is constructed. State-Space Planning Each node represents a state of the world. A plan is a path through this space. Plan-Space Planning Each node is a set of partially instantiated operators, and a set of constraints. Constraints are added until we get a plan. Search Types Forward Search (SHOP2) Start at initial state and apply operators. Construct graph of state space. Search from initial state to goal. Can have a very large branching factor. Search Types Backward Search (STRIPS) State-Space search Starts at goal. Searches backwards to initial state. Efficient but less expressive Example UCPOP Domain Hierarchical Task Networks HTNs can be used to form complex plans. Two types of Operators (Methods). Methods form a hierarchy of tasks. Complex – Composed of subtasks Simple – Executes directly Method Structure Complex Method Name( parameter list ) Precondition set 1 Task list 1 … Precondition set n Task list n Sample Task Hierarchy Method Travel( location1, location2 ) Precondition 1: ShortDistance( loc1, loc2 ) Tasks 1: get_taxi Ride( loc1, loc2 ) Pay_driver Method Travel()… Method Travel( location1, location2 ) Precondition 2: LongDistance( loc1, loc2 ) Tasks 2: get_airplane_ticket( loc1, loc2 ) Travel( loc1, loc1(airport) ) Fly( loc1(airport), loc2(airport) ) Travel( loc2(airport), loc2 ) Method Structure Simple Method Name( parameter list ) Precondition set Delete list Add List Method ride() Ride( loc1, loc2 ) Preconditions: ShortDistance( loc1, loc2 ) Delete: (at Joe loc1) Add: (at Joe loc2) The SHOP2 Planner Created at University of Maryland in 2002 Language for developing HTNs Input: Planning domain and problem set. Output: Java program to implement planner. Sample SHOP2 Domains Planning in Games / Simulation Most systems use FSM. Planning offers more behaviors, flexibility. Warcraft 2 Project