def parse_action(alist): iterator = iter(alist) assert iterator.next() == ":action" name = iterator.next() parameters_tag_opt = iterator.next() if parameters_tag_opt == ":parameters": parameters = pddl_types.parse_typed_object_list(iterator.next(), variable_names=True) precondition_tag_opt = iterator.next() else: parameters = [] precondition_tag_opt = parameters_tag_opt if precondition_tag_opt == ":precondition": precondition = parse_precondition(iterator.next()) effect_tag = iterator.next() else: precondition = [] effect_tag = precondition_tag_opt assert effect_tag == ":effect" effect_list = iterator.next() add_effects = [] del_effects = [] parse_effect_list(effect_list, add_effects, del_effects) for rest in iterator: assert False, rest return Action(name, parameters, precondition, add_effects, del_effects)
def parse_action(alist): iterator = iter(alist) assert iterator.next() == ":action" name = iterator.next() parameters_tag_opt = iterator.next() if parameters_tag_opt == ":parameters": parameters = pddl_types.parse_typed_object_list(iterator.next(), variable_names=True) precondition_tag_opt = iterator.next() else: parameters = [] precondition_tag_opt = parameters_tag_opt if precondition_tag_opt == ":precondition": precondition = parse_precondition(iterator.next()) effect_tag = iterator.next() else: precondition = [] effect_tag = precondition_tag_opt assert effect_tag == ":effect" effect_list = iterator.next() add_effects = [] del_effects = [] parse_effect_list(effect_list, add_effects, del_effects) for rest in iterator: assert False, rest return Action(name, parameters, precondition, add_effects, del_effects)
def parse_task(task_pddl): iterator = iter(task_pddl) assert iterator.next() == "define" problem_line = iterator.next() assert problem_line[0] == "problem" and len(problem_line) == 2 problem_name = problem_line[1] domain_line = iterator.next() assert domain_line[0] == ":domain" and len(domain_line) == 2 #yield domain_line[1] # Check if the :objects are specified objects_opt = iterator.next() if objects_opt[0] == ":objects": object_list = pddl_types.parse_typed_object_list(objects_opt[1:]) init = iterator.next() else: object_list = [] init = objects_opt # Parse :init assert init[0] == ":init" and len(init) > 1 init_list = states.parse_state_list(init[1:]) # Parse :goal goal = iterator.next() assert goal[0] == ":goal" and len(goal) == 2 goal_list = states.parse_state_list(goal[1]) return [problem_name, object_list, init_list, goal_list]
def parse_predicate(alist): name = alist[0] arguments = pddl_types.parse_typed_object_list(alist[1:], variable_names=True) return Predicate(name, arguments)
def parse_predicate(alist): name = alist[0] arguments = pddl_types.parse_typed_object_list(alist[1:], variable_names=True) return Predicate(name, arguments)