/////////// In this class, the instance variable that /////////// holds the list of literals that represents /////////// the state description is assumed to be /////////// called "literal" public class PlanningState implements State { /** Determines whether the state matches all of the conditions (literals) in a goal. @return true iff all the conditions of the goal are satisfied */ // Recall that under classical planning assumptions, all // terms in state literals and goal literals are object // constants, so matching can be done without dealing // with substitution or unification. public boolean isGoal() { return goal.size() == literals.countSatisfiedSubgoals(goal); } /** Return an estimator suitable for A*, in the context of classical planning. The estimator is not necessarily optimistic, so it may not lead to the shortest possible plan. @return the priority of expanding the state (lower values give priority over higher values) */ public double findEstimate() { return 2 * (goal.size() - literals.countSatisfiedSubgoals(goal)) + history.size(); } }