planning with certainty def is_goal(selfsubgoal)"""if subgoal is true in the initial statea path has been found""goal_asst subgoal assignment return all(self initial_state[ ]==goal_asst[gfor in goal_asst def start_node(self)"""the start node is the top-level goal""return self top_goal def neighbors(self,subgoal)"""returns list of the arcs for the neighbors of subgoal in this problem""goal_asst subgoal assignment return arc(subgoalself weakest_precond(act,goal_asst)act costactfor act in self prob_domain actions if self possible(act,goal_asst) def possible(self,act,goal_asst)"""true if act is possible to achieve goal_asst the action achieves an element of the effects and the action doesn' delete something that needs to be achieved and the preconditions are consistent with other subgoals that need to be achieved ""return any(goal_asst[prop=act effects[propfor prop in act effects if prop in goal_asstand all(goal_asst[prop=act effects[propfor prop in act effects if prop in goal_asstand all(goal_asst[prop]=act preconds[propfor prop in act preconds if prop not in act effects and prop in goal_asst def weakest_precond(self,act,goal_asst)"""returns the subgoal that must be true so goal_asst holds after act should beact preconds (goal_asst act effects""new_asst act preconds copy(for in goal_asstif not in act effectsnew_asst[ggoal_asst[greturn subgoal(new_asst def heuristic(self,subgoal)"""in the regression planner node is subgoal version june