An HTN Planner in JavaScript
Warren Sack
- This is the definition of a hierarchical task network (HTN) planner: Code/Plan/shop.js
- A very simple example that defines (a) an initial state; (b) a task; (c) actions/operators; and, (d) methods can be found here: Code/Plan/basicExample.js
- Here is a more complicated "blocks world" example: Code/Plan/unstackAll.js
- Note that the planner returns a successful state from the search space it has tried. However, it also keeps the entire tree of search states that it has tried. Since each of these states are represented in JSON, the entire set of search states can be loaded into the database and another set of planning methods authored in order to select and order interesting elements from the search state. Here is a simple example of such methods that, in fact, only contains one action. It selects interesting actions out of the search state for the "blocks world" example: Code/Plan/planBlocksDisplay.js
- The output of the second planner is (1) a set of labels representing blocks (e.g., a, b, c, etc.); (2) a set of "on" statements describing the initial positions of the blocks (e.g., on(a,b), on(b,c), etc.); and, (3) a series of "move" actions planned to transform the initial state into the goal state (e.g., move(c,table)). The final "layer" of this planning system accepts the output of the second planner as a sequence of instructions for graphically rendering the planning process: Code/Plan/displayBlocks.js
- This file executes the first planner, then the second, and hands the results to the graphical interpreter. Code/Plan/planAndDisplayBlocks.html
- Download all of the code here. Send me an email if you do use the code: wsack@ucsc.edu. Thanks!