Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package jason.asSyntax.patterns.goal;
 
Implementation of the Sequenced Goal Adoption pattern (see DALT 2006 paper)

Author(s):
jomi
public class SGA implements Directive {
    static Logger logger = Logger.getLogger(SGA.class.getName());
    
    public Agent process(Pred directiveAgent outerContentAgent innerContent) {
        try {
            Trigger trigger = ASSyntax.parseTrigger(((StringTerm)directive.getTerm(0)).getString());
            LogicalFormula context = LogExpr.parseExpr(((StringTerm)directive.getTerm(1)).getString());
            Term goal = directive.getTerm(2);
            
            Agent newAg = new Agent();
            newAg.initAg();
            // add t : not f__l(_) & c <- !f__g(g).
            newAg.getPL().add(ASSyntax.parsePlan(trigger+" : not f__l(_) & " +context +" <- !f__g("+goal+")."));
            
            // add t : f__l(_) & c <- +f__l(g).
            newAg.getPL().add(ASSyntax.parsePlan(trigger+" : f__l(_) & (" +context +") <- +f__l("+goal+")."));
            
            // add +!fg(g) : true <- +fl(g); !g; -fl(g)
            newAg.getPL().add(ASSyntax.parsePlan("+!f__g("+goal+") <- +f__l("+goal+"); !"+goal+"; -f__l("+goal+")."));            
            
            // add -!fg(g) : true <- -fl(g)
            newAg.getPL().add(ASSyntax.parsePlan("-!f__g("+goal+") <- -f__l("+goal+")."));            
            // add -fl(_) : fg(g) <- !fg(g)
            newAg.getPL().add(ASSyntax.parsePlan("-f__l("+goal+") : f__l("+goal+") <- !f__g("+goal+")."));            
            return newAg;
        } catch (Exception e) {
            .log(.,"Directive DG error."e);
        }
        return null;
    }
New to GrepCode? Check out our FAQ X