
Copyright © 2005-2007 Philippe Fournier-Viger
All rights reserved.
This example shows how to load a problem from a file with PL-PLAN and then find a plan.
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.

PLPlan planner = new PLPlan();
planner = new PLPlan();
planner.setAlgorithm(EnumAlgorithm.FW_SS_SM_0);
planner.readFactsFromFile("BlockWorld8c.txt"); <-- click on the link to see the file
planner.readGoalFromFile("BlockWorld8c.txt");
planner.readOperatorsFromFile("BlockWorld8c.txt");
List resultats = planner.findPlan();
System.out.println(resultats);
The solution : [uBA, uAG, uGC, uCH, sCA, sFC, sBF]