All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jason.asSyntax.patterns.goal.BDG Maven / Gradle / Ivy

Go to download

Jason is a fully-fledged interpreter for an extended version of AgentSpeak, a BDI agent-oriented logic programming language.

There is a newer version: 2.3
Show newest version
package jason.asSyntax.patterns.goal;

import jason.asSemantics.Agent;
import jason.asSyntax.ASSyntax;
import jason.asSyntax.Pred;
import jason.asSyntax.Term;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Implementation of the Backtracking Declarative Goal pattern (see DALT 2006 paper)
 * 
 * @author jomi
 */
public class BDG extends DG {

    static Logger logger = Logger.getLogger(BDG.class.getName());
    
    public Agent process(Pred directive, Agent outerContent, Agent innerContent) {
        try {
            // apply DG in the inner plans
            Agent newAg = super.process(directive, outerContent, innerContent); 
            if (newAg != null) {

                Term goal = directive.getTerm(0);
    
                // add -!g : true <- !!g.
                newAg.getPL().add(ASSyntax.parsePlan("-!"+goal+" <- !!"+goal+"."));
                
                return newAg;
            }
        } catch (Exception e) {
            logger.log(Level.SEVERE,"Directive error.", e);
        }
        return null;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy