Esempio n. 1
0
def parse_effect(alist):
    tag = alist[0]
    if tag == "and":
        return [
            ConjunctiveEffect(conjuncts) for conjuncts in cartesian_product(
                *[parse_effect(eff) for eff in alist[1:]])
        ]
    elif tag == "forall":
        assert len(alist) == 3
        parameters = pddl_types.parse_typed_list(alist[1])
        effects = parse_effect(alist[2])
        assert 1 == len(
            effects
        ), "Error: Cannot embed non-determinism inside of a forall (for now)."
        return [UniversalEffect(parameters, effect) for effect in effects]
    elif tag == "when":
        assert len(alist) == 3
        condition = conditions.parse_condition(alist[1])
        effects = parse_effect(alist[2])
        return [ConditionalEffect(condition, effect) for effect in effects]
    elif tag == "increase":
        assert len(alist) == 3
        assert alist[1] == ['total-cost']
        assignment = f_expression.parse_assignment(alist)
        return [CostEffect(assignment)]
    elif tag == "oneof":
        options = []
        for eff in alist[1:]:
            options.extend(parse_effect(eff))
        return options
    else:
        return [SimpleEffect(conditions.parse_literal(alist))]
Esempio n. 2
0
def parse_effects(effect_list, result):
    """Parse a STRIPS effect
       
	The Effect class
       
 	ConjunctionEffects are effects containing conjunctions
	LiteralEffects are normal effects
    """

    token = effect_list[0]    
    args = effect_list[1:]

    def parse_effect(eff_list): #anonymous worker function
    	conjunct = eff_list[0]
    	if conjunct == "and":
    	    return ConjunctionEffect([parse_effect(eff) for eff in eff_list[1:]])
    	else:
    	    return Literal_Effect(conditions.parse_literal(eff_list))
    
    if token == "and":
        eff = ConjunctionEffect([parse_effect(eff) for eff in args])
    else:
        eff = Literal_Effect(conditions.parse_literal(effect_list))
    
    add_effect(eff, result)
def parse_effect(alist):
    tag = alist[0]
    if tag == "and":
      return ConjunctiveEffect([parse_effect(eff) for eff in alist[1:]])
    elif tag == "forall":
      assert len(alist) == 3
      parameters = pddl_types.parse_typed_list(alist[1])
      effect = parse_effect(alist[2])
      return UniversalEffect(parameters, effect)
    elif tag == "when":
      assert len(alist) == 3
      condition = conditions.parse_condition(alist[1])
      effect = parse_effect(alist[2])
      return ConditionalEffect(condition, effect)
    elif tag == "increase":
      assert len(alist) == 3
      assert alist[1] == ['total-cost']
      assignment = f_expression.parse_assignment(alist)
      return CostEffect(assignment)
    else:
        return SimpleEffect(conditions.parse_literal(alist))
Esempio n. 4
0
def parse_effect(alist):
    tag = alist[0]
    if tag == "and":
        return ConjunctiveEffect([parse_effect(eff) for eff in alist[1:]])
    elif tag == "forall":
        assert len(alist) == 3
        parameters = pddl_types.parse_typed_list(alist[1])
        effect = parse_effect(alist[2])
        return UniversalEffect(parameters, effect)
    elif tag == "when":
        assert len(alist) == 3
        condition = conditions.parse_condition(alist[1])
        effect = parse_effect(alist[2])
        return ConditionalEffect(condition, effect)
    elif tag == "increase":
        assert len(alist) == 3
        assert alist[1] == ['total-cost']
        assignment = f_expression.parse_assignment(alist)
        return CostEffect(assignment)
    else:
        return SimpleEffect(conditions.parse_literal(alist))
Esempio n. 5
0
 def parse_effect(eff_list): #anonymous worker function
 	conjunct = eff_list[0]
 	if conjunct == "and":
 	    return ConjunctionEffect([parse_effect(eff) for eff in eff_list[1:]])
 	else:
 	    return Literal_Effect(conditions.parse_literal(eff_list))