Example 2 - PL-PLAN: A Java Open-Source AI Planner

PL-PLAN : A Java Open-Source AI Planner

    Example 2

    This example shows how to load a problem from a file with PL-PLAN and then find a plan.

    The problem

    The problem is the classic Blockworld problem. There is eight blocks on a table, as illustrated bellow. The Example2.java class utilize PL-PLAN to find a plan to go from the initial state to the goal state. A plan consists of applying a sequence of action. Each action is the application of an operator. In the blockworld problem, it is only possible to move one block at a time. For instance, in this example, "uAB" (unstack A from B), "uBC" (unstack B from C) and "sDB" (stack D on B) are operators.

    The Java Code

    PLPlan planner = new PLPlan();
     planner = new PLPlan();
     planner.readFactsFromFile("BlockWorld8c.txt"); <-- click on the link to see the file 
     List resultats = planner.findPlan();

    The Console Output

    The solution : [uBA, uAG, uGC, uCH, sCA, sFC, sBF]