Example #1
0
  /**
   * Executes this action.
   *
   * @param module the module to execute this action for.
   * @return true if the action succeeds, false otherwise.
   */
  public PlanResult execute(APLModule module) {
    Beliefbase beliefs = module.getBeliefbase();
    PCrulebase pcrules = module.getPCrulebase();
    plan.evaluateArguments();

    SubstList<Term> theta = new SubstList<Term>();

    PCrule rule;
    try {
      rule = pcrules.selectRule(beliefs, plan, getTopParent().getVariables(), theta, module);
    } catch (NoRuleException e) {
      return new PlanResult(this, PlanResult.FAILED);
    }

    if (rule != null) {
      PlanSeq p = rule.getBody().clone();
      p.applySubstitution(theta);

      parent.removeFirst();
      parent.addFirst(p);
      return new PlanResult(this, PlanResult.SUCCEEDED);
    } else return new PlanResult(this, PlanResult.FAILED);
  }
Example #2
0
 /** @return clone of the PC rulebase */
 public PCrulebase clone() {
   PCrulebase b = new PCrulebase();
   b.setRules(getRules());
   return b;
 }