本文整理汇总了Java中jason.asSyntax.Plan.parse方法的典型用法代码示例。如果您正苦于以下问题:Java Plan.parse方法的具体用法?Java Plan.parse怎么用?Java Plan.parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jason.asSyntax.Plan
的用法示例。
在下文中一共展示了Plan.parse方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import jason.asSyntax.Plan; //导入方法依赖的package包/类
protected void setUp() throws Exception {
super.setUp();
intention1 = new Intention();
Plan p = Plan.parse("+!g0 : true <- !g1; !g4.");
intention1.push(new IntendedMeans(new Option(p,new Unifier()), null));
p = Plan.parse("+!g1 : true <- !g2.");
intention1.push(new IntendedMeans(new Option(p,new Unifier()), null));
p = Plan.parse("+!g2 : true <- !g4; f;g.");
intention1.push(new IntendedMeans(new Option(p,new Unifier()), null));
p4 = Plan.parse("+!g4 : true <- h.");
intention1.push(new IntendedMeans(new Option(p4,new Unifier()), null));
p5 = Plan.parse("+!g5 : true <- i.");
ag = new Agent();
ag.initAg();
ag.getPL().add(Plan.parse("-!g1 : true <- j."));
}
示例2: setUp
import jason.asSyntax.Plan; //导入方法依赖的package包/类
protected void setUp() throws Exception {
super.setUp();
intention1 = new Intention();
Plan p = Plan.parse("+!g0 : true <- !g1; !g4.");
intention1.push(new IntendedMeans(new Option(p,new Unifier()), null));
p = Plan.parse("+!g1 : true <- !g2.");
intention1.push(new IntendedMeans(new Option(p,new Unifier()), null));
p = Plan.parse("+!g2 : true <- !g4; f;g.");
intention1.push(new IntendedMeans(new Option(p,new Unifier()), null));
p4 = Plan.parse("+!g4 : true <- h.");
intention1.push(new IntendedMeans(new Option(p4,new Unifier()), null));
p5 = Plan.parse("+!g5 : true <- i.");
ag = new Agent();
ag.initAg();
ag.getPL().add(Plan.parse("-!g1 : true <- j."));
}
示例3: testAnnots
import jason.asSyntax.Plan; //导入方法依赖的package包/类
public void testAnnots() {
Plan p1 = Plan.parse("@l[atomic,breakpoint] +e.");
Plan p2 = Plan.parse("+e : c <- a.");
assertTrue(p1.isAtomic());
assertFalse(p2.isAtomic());
assertTrue(p1.hasBreakpoint());
assertFalse(p2.hasBreakpoint());
Plan p3 = (Plan) p1.clone();
assertTrue(p3.isAtomic());
assertTrue(p3.hasBreakpoint());
}
示例4: testDelete
import jason.asSyntax.Plan; //导入方法依赖的package包/类
public void testDelete() {
Plan p = Plan.parse("+te : a & b <- !a1; ?a2; .print(a); !g1.");
assertEquals(4, p.getBody().getPlanSize());
p.getBody().removeBody(0);
assertEquals(3, p.getBody().getPlanSize());
assertEquals(PlanBody.BodyType.test, p.getBody().getBodyType());
p.getBody().removeBody(0); // 2
p.getBody().removeBody(0); // 1
assertEquals(1, p.getBody().getPlanSize());
p.getBody().removeBody(0); // 1
assertTrue(p.getBody().isEmptyBody());
}
示例5: testEqualsBodyLiteral
import jason.asSyntax.Plan; //导入方法依赖的package包/类
public void testEqualsBodyLiteral() {
PlanBody bl = new PlanBodyImpl(BodyType.achieve, new LiteralImpl("g1"));
VarTerm v = new VarTerm("X");
Unifier u = new Unifier();
// X = !g1
assertTrue(u.unifies(v, bl));
PlanBody vb = (PlanBody)v.capply(u);
assertEquals(BodyType.achieve, vb.getBodyType());
assertEquals(bl.getBodyTerm(),vb.getBodyTerm());
Plan p = Plan.parse("+te : a & b <- !g1.");
assertEquals(p.getBody(),vb);
}
示例6: testUnifyBody
import jason.asSyntax.Plan; //导入方法依赖的package包/类
public void testUnifyBody() {
Plan p1 = Plan.parse("+te : a & b <- !a1; ?a2; .print(a); !g1.");
PlanBody bl = new PlanBodyImpl(BodyType.action, new VarTerm("A1"));
bl.add(new PlanBodyImpl(BodyType.action, new VarTerm("A2")));
bl.add(new PlanBodyImpl(BodyType.action, new VarTerm("A3")));
//assertEquals(p1.getBody().getArity(), bl.getArity());
Unifier u = new Unifier();
assertTrue(u.unifies(p1.getBody(), bl));
assertEquals("a1", u.get("A1").toString());
assertEquals("a2", u.get("A2").toString());
assertEquals(".print(a); !g1", u.get("A3").toString());
}
示例7: testUnifyBody
import jason.asSyntax.Plan; //导入方法依赖的package包/类
public void testUnifyBody() {
Plan p1 = Plan.parse("+te : a & b <- !a1; ?a2; .print(a); !g1.");
PlanBody bl = new PlanBodyImpl(BodyType.action, new VarTerm("A1"));
bl.add(new PlanBodyImpl(BodyType.action, new VarTerm("A2")));
bl.add(new PlanBodyImpl(BodyType.action, new VarTerm("A3")));
//assertEquals(p1.getBody().getArity(), bl.getArity());
Unifier u = new Unifier();
assertTrue(u.unifies(p1.getBody(), bl));
assertEquals("a1", u.get("A1").toString());
assertEquals("a2", u.get("A2").toString());
assertEquals(".print(a); !g1", u.get("A3").toString());
}
示例8: testSingletonVars
import jason.asSyntax.Plan; //导入方法依赖的package包/类
public void testSingletonVars() {
Literal l = Literal.parseLiteral("a(10)");
assertEquals(0, l.getSingletonVars().size());
l = Literal.parseLiteral("a(X)");
assertEquals(1, l.getSingletonVars().size());
l = Literal.parseLiteral("a(X,X)");
assertEquals(0, l.getSingletonVars().size());
l = Literal.parseLiteral("a(_X,_Y,_X)");
assertEquals(0, l.getSingletonVars().size());
l = Literal.parseLiteral("a(X,Y,b(g(X),c))");
assertEquals(1, l.getSingletonVars().size());
assertEquals("Y", l.getSingletonVars().get(0).toString());
l = Literal.parseLiteral("a(X,Y,b(g(X),c))[b,source(Y)]");
assertEquals(0, l.getSingletonVars().size());
l = Literal.parseLiteral("a(Test,X,Y,b(g(X),c))[b,source(Y),B,kk(U)]");
assertEquals(3, l.getSingletonVars().size());
l = Literal.parseLiteral("a(Test,X,Y,b(g([V1,X,V2,V1]),c))[b,source(Y),B,kk(_)]");
assertEquals(3, l.getSingletonVars().size());
Plan p = Plan.parse("+e(X) : X > 10 <- .print(ok).");
assertEquals(0, p.getSingletonVars().size());
p = Plan.parse("+e(x) : X > 10 <- .print(ok).");
assertEquals(1, p.getSingletonVars().size());
assertEquals("X", p.getSingletonVars().get(0).toString());
p = Plan.parse("+e(x) : a(X) & X > 10 <- .print(ok).");
assertEquals(0, p.getSingletonVars().size());
p = Plan.parse("+e(x) : a(X) & X > 10 <- .print(W).");
assertEquals(1, p.getSingletonVars().size());
p = Plan.parse("+e(x) : a(X, { +!g(W) <- true }) & X > 10 <- .print(W).");
assertEquals(0, p.getSingletonVars().size());
p = Plan.parse("+e(x) : a(X) & X > 10 <- .print(_).");
assertEquals(0, p.getSingletonVars().size());
}
示例9: testSingletonVars
import jason.asSyntax.Plan; //导入方法依赖的package包/类
public void testSingletonVars() {
Literal l = Literal.parseLiteral("a(10)");
assertEquals(0, l.getSingletonVars().size());
l = Literal.parseLiteral("a(X)");
assertEquals(1, l.getSingletonVars().size());
l = Literal.parseLiteral("a(X,X)");
assertEquals(0, l.getSingletonVars().size());
l = Literal.parseLiteral("a(_X,_Y,_X)");
assertEquals(0, l.getSingletonVars().size());
l = Literal.parseLiteral("a(X,Y,b(g(X),c))");
assertEquals(1, l.getSingletonVars().size());
assertEquals("Y", l.getSingletonVars().get(0).toString());
l = Literal.parseLiteral("a(X,Y,b(g(X),c))[b,source(Y)]");
assertEquals(0, l.getSingletonVars().size());
l = Literal.parseLiteral("a(Test,X,Y,b(g(X),c))[b,source(Y),B,kk(U)]");
assertEquals(3, l.getSingletonVars().size());
l = Literal.parseLiteral("a(Test,X,Y,b(g([V1,X,V2,V1]),c))[b,source(Y),B,kk(_)]");
assertEquals(3, l.getSingletonVars().size());
Plan p = Plan.parse("+e(X) : X > 10 <- .print(ok).");
assertEquals(0, p.getSingletonVars().size());
p = Plan.parse("+e(x) : X > 10 <- .print(ok).");
assertEquals(1, p.getSingletonVars().size());
assertEquals("X", p.getSingletonVars().get(0).toString());
p = Plan.parse("+e(x) : a(X) & X > 10 <- .print(ok).");
assertEquals(0, p.getSingletonVars().size());
p = Plan.parse("+e(x) : a(X) & X > 10 <- .print(W).");
assertEquals(1, p.getSingletonVars().size());
p = Plan.parse("+e(x) : a(X, { +!g(W) <- true }) & X > 10 <- .print(W).");
assertEquals(0, p.getSingletonVars().size());
p = Plan.parse("+e(x) : a(X) & X > 10 <- .print(_).");
assertEquals(0, p.getSingletonVars().size());
}