本文整理汇总了Java中jason.asSyntax.Literal.addAnnot方法的典型用法代码示例。如果您正苦于以下问题:Java Literal.addAnnot方法的具体用法?Java Literal.addAnnot怎么用?Java Literal.addAnnot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jason.asSyntax.Literal
的用法示例。
在下文中一共展示了Literal.addAnnot方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addInitialGoalsFromProjectInBB
import jason.asSyntax.Literal; //导入方法依赖的package包/类
protected void addInitialGoalsFromProjectInBB() {
String sGoals = getTS().getSettings().getUserParameter(Settings.INIT_GOALS);
if (sGoals != null) {
try {
for (Term t: ASSyntax.parseList("["+sGoals+"]")) {
Literal g = ((Literal)t).forceFullLiteralImpl();
g.makeVarsAnnon();
if (! g.hasSource())
g.addAnnot(BeliefBase.TSelf);
getTS().getC().addAchvGoal(g,Intention.EmptyInt);
}
} catch (Exception e) {
logger.log(Level.WARNING, "Initial goals from project '["+sGoals+"]' is not a list of literals.");
}
}
}
示例2: testFindAll
import jason.asSyntax.Literal; //导入方法依赖的package包/类
public void testFindAll() throws RevisionFailedException, ParseException {
Agent ag = new Agent();
ag.initAg();
Literal l1 = Literal.parseLiteral("a(10,x)");
assertFalse(l1.hasSource());
ag.addBel(l1);
ag.addBel(Literal.parseLiteral("a(20,y)"));
ag.addBel(Literal.parseLiteral("a(30,x)"));
assertEquals(ag.getBB().size(),3);
Unifier u = new Unifier();
Term X = ASSyntax.parseTerm("f(X)");
Literal c = Literal.parseLiteral("a(X,x)");
c.addAnnot(BeliefBase.TSelf);
VarTerm L = new VarTerm("L");
// System.out.println(ag.getPS().getAllRelevant(Trigger.parseTrigger(ste.getFunctor())));
try {
assertTrue((Boolean)new jason.stdlib.findall().execute(ag.getTS(), u, new Term[] { X, c, L }));
} catch (Exception e) {
e.printStackTrace();
}
ListTerm lt = (ListTerm) u.get("L");
//System.out.println("found=" + lt);
assertEquals(lt.size(), 2);
}
示例3: process
import jason.asSyntax.Literal; //导入方法依赖的package包/类
@Override
public Agent process(Pred directive, Agent outerContent, Agent innerContent) {
try {
Literal goal = Literal.parseLiteral(directive.getTerm(0).toString());
Pred subDir;
if (directive.getArity() > 1) {
subDir = Pred.parsePred(directive.getTerm(1).toString());
} else {
subDir = Pred.parsePred("bc("+goal+")");
}
Directive sd = DirectiveProcessor.getDirective(subDir.getFunctor());
// apply sub directive
Agent newAg = sd.process(subDir, outerContent, innerContent);
if (newAg != null) {
// add bel g
Literal ig = goal.copy();
ig.addAnnot(BeliefBase.TPercept);
newAg.addInitialBel(goal);
// 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;
}
示例4: addInitialGoalsInTS
import jason.asSyntax.Literal; //导入方法依赖的package包/类
/** includes all initial goals in the agent reasoner */
public void addInitialGoalsInTS() {
for (Literal g: initialGoals) {
g.makeVarsAnnon();
if (! g.hasSource())
g.addAnnot(BeliefBase.TSelf);
getTS().getC().addAchvGoal(g,Intention.EmptyInt);
}
initialGoals.clear();
}
示例5: addBel
import jason.asSyntax.Literal; //导入方法依赖的package包/类
/**
* Adds <i>bel</i> in belief base (calling brf) and generates the
* events. If <i>bel</i> has no source, add
* <code>source(self)</code>. (the belief is not cloned!)
*/
public boolean addBel(Literal bel) throws RevisionFailedException {
if (!bel.hasSource()) {
bel.addAnnot(BeliefBase.TSelf);
}
List<Literal>[] result = brf(bel, null, Intention.EmptyInt);
if (result != null && ts != null) {
ts.updateEvents(result, Intention.EmptyInt);
return true;
} else {
return false;
}
}
示例6: delBel
import jason.asSyntax.Literal; //导入方法依赖的package包/类
/**
* If the agent believes in <i>bel</i>, removes it (calling brf)
* and generate the event.
*/
public boolean delBel(Literal bel) throws RevisionFailedException {
if (!bel.hasSource()) {
bel.addAnnot(BeliefBase.TSelf);
}
List<Literal>[] result = brf(null, bel, Intention.EmptyInt);
if (result != null && ts != null) {
ts.updateEvents(result, Intention.EmptyInt);
return true;
} else {
return false;
}
}