本文整理汇总了Java中jason.asSyntax.Literal.makeVarsAnnon方法的典型用法代码示例。如果您正苦于以下问题:Java Literal.makeVarsAnnon方法的具体用法?Java Literal.makeVarsAnnon怎么用?Java Literal.makeVarsAnnon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jason.asSyntax.Literal
的用法示例。
在下文中一共展示了Literal.makeVarsAnnon方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: testMakeVarAnnon1
import jason.asSyntax.Literal; //导入方法依赖的package包/类
public void testMakeVarAnnon1() {
Literal l1 = Literal.parseLiteral("likes(jane,X,peter)");
Literal l2 = Literal.parseLiteral("likes(X,Y,Y)");
Literal l3 = Literal.parseLiteral("likes(X,Y,X)");
Literal l4 = Literal.parseLiteral("likes(Z,Y,Y)");
Unifier u = new Unifier();
assertFalse(u.unifies(l1, l2));
u.clear();
assertFalse(u.unifies(l1, l3));
u.clear();
assertTrue(u.unifies(l1, l4));
l2.makeVarsAnnon();
u.clear();
assertTrue(u.unifies(l1, l2));
l3.makeVarsAnnon();
u.clear();
assertFalse(u.unifies(l1, l3));
l4.makeVarsAnnon();
u.clear();
assertTrue(u.unifies(l1, l4));
}
示例3: 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();
}
示例4: testMakeVarAnnon3
import jason.asSyntax.Literal; //导入方法依赖的package包/类
public void testMakeVarAnnon3() {
Literal l1 = Literal.parseLiteral("calc(AgY,X)[vl(X),source(AgY),bla(Y),X]");
l1.makeVarsAnnon();
Map<VarTerm, Integer> v = new HashMap<VarTerm, Integer>();
l1.countVars(v);
assertEquals(3, v.size());
assertEquals("vl("+l1.getTerm(1)+")",l1.getAnnots("vl").get(0).toString());
l1 = Literal.parseLiteral("calc(a)[a,b|T]");
assertFalse(l1.isGround());
l1.makeVarsAnnon();
assertFalse(l1.isGround());
assertTrue(l1.toString().contains("_"));
assertFalse("calc(a)[a,b|T]".equals(l1.toString()));
}
示例5: testMakeVarAnnon4
import jason.asSyntax.Literal; //导入方法依赖的package包/类
public void testMakeVarAnnon4() {
Literal l = Literal.parseLiteral("p(X)");
Unifier u = new Unifier();
u.unifies(new UnnamedVar(4), new VarTerm("X"));
u.unifies(new VarTerm("X"), new UnnamedVar(2));
u.unifies(new UnnamedVar(2), new VarTerm("Y"));
u.unifies(new UnnamedVar(10), new VarTerm("Y"));
u.unifies(new VarTerm("X"), new VarTerm("Z"));
/*
Iterator<VarTerm> i = u.binds(new VarTerm("X"));
while (i.hasNext()) {
System.out.println(i.next());
}
*/
l.makeVarsAnnon(u);
// ensure that X derefs to _10
assertTrue(u.deref(new VarTerm("X")).equals(new UnnamedVar(10)));
// ensure that unifying a value with X will bind a value for all aliases as well.
Term val = new StringTermImpl("value");
u.unifies(new VarTerm("X"), val);
assertTrue(u.get(new VarTerm("X")).equals(val));
assertTrue(u.get(new VarTerm("Y")).equals(val));
assertTrue(u.get(new VarTerm("Z")).equals(val));
assertTrue(u.get(new UnnamedVar(4)).equals(val));
assertTrue(u.get(new UnnamedVar(2)).equals(val));
assertTrue(u.get(new UnnamedVar(10)).equals(val));
}
示例6: testMakeVarAnnon5
import jason.asSyntax.Literal; //导入方法依赖的package包/类
public void testMakeVarAnnon5() {
Literal l = Literal.parseLiteral("p(X,Y)[s(Y)]");
Unifier u = new Unifier();
u.unifies(new VarTerm("X"), new VarTerm("Y"));
l.makeVarsAnnon(u);
assertEquals(l.getTerm(0), l.getTerm(1));
assertEquals("[s("+l.getTerm(0)+")]", l.getAnnots().toString());
}
示例7: testMakeVarAnnon6
import jason.asSyntax.Literal; //导入方法依赖的package包/类
public void testMakeVarAnnon6() {
UnnamedVar v1 = new UnnamedVar();
UnnamedVar v2 = new UnnamedVar();
Literal l = ASSyntax.createLiteral("p", v1, v2, ASSyntax.createList(v1,v2));
l.makeVarsAnnon();
// vars inside the list should be replaced as var placed in term0 and term1
assertEquals(l.getTerm(0).toString(), ((ListTerm)l.getTerm(2)).get(0).toString());
}