Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package jason.asSyntax.patterns.goal;
 
 
Implementation of the Single-Minded Commitment pattern (see DALT 2006 paper)

Author(s):
jomi
public class SMC implements Directive {
    static Logger logger = Logger.getLogger(SMC.class.getName());
    
    public Agent process(Pred directiveAgent outerContentAgent innerContent) {
        try {
            Term goal = directive.getTerm(0);
            Term fail = directive.getTerm(1);
            Pred subDir = Pred.parsePred("bc("+goal+")");
            //logger.fine("parameters="+goal+","+fail+","+subDir);
            Directive sd = DirectiveProcessor.getDirective(subDir.getFunctor());
            // apply sub directive
            Agent newAg = sd.process(subDirouterContentinnerContent); 
            if (newAg != null) {
                // add +f : true <- .fail_goal(g).
                newAg.getPL().add(ASSyntax.parsePlan("+"+fail+" <- .fail_goal("+goal+")."));
                
                return newAg;
            }
        } catch (Exception e) {
            .log(.,"Directive error."e);
        }
        return null;
    }
New to GrepCode? Check out our FAQ X