本文整理汇总了Java中jason.asSyntax.ListTermImpl类的典型用法代码示例。如果您正苦于以下问题:Java ListTermImpl类的具体用法?Java ListTermImpl怎么用?Java ListTermImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ListTermImpl类属于jason.asSyntax包,在下文中一共展示了ListTermImpl类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: perceive
import jason.asSyntax.ListTermImpl; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public List<Literal> perceive() {
if (!isRunning()) return null;
if (getEnvironmentAg() == null) return null;
@SuppressWarnings("rawtypes")
List percepts = null;
try {
ACLMessage askMsg = new ACLMessage(ACLMessage.QUERY_REF);
askMsg.addReceiver(environmentAID);
askMsg.setOntology(JadeEnvironment.perceptionOntology);
askMsg.setContent("getPercepts");
ACLMessage r = jadeAg.ask(askMsg);
if (r != null && r.getContent().startsWith("[")) {
percepts = ListTermImpl.parseList(r.getContent());
}
} catch (Exception e) {
logger.log(Level.SEVERE, "Error in perceive.", e);
}
return percepts;
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:24,代码来源:JasonBridgeArch.java
示例2: execute
import jason.asSyntax.ListTermImpl; //导入依赖的package包/类
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
try {
Literal pattern = (Literal)args[0];
ListTerm result = new ListTermImpl();
synchronized (ts.getAg().getBB().getLock()) {
Iterator<Literal> i = ts.getAg().getBB().getCandidateBeliefs(pattern, un);
while (i.hasNext()) {
Literal l = i.next();
if (l.isRule()) {
if (un.clone().unifies(pattern, l)) {
l = l.copy();
l.delSources();
((Rule)l).setAsTerm(true);
result.add(l);
}
}
}
}
return un.unifies(args[1],result);
} catch (Exception e) {
ts.getLogger().warning("Error in internal action 'get_rules'! "+e);
}
return false;
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:26,代码来源:relevant_rules.java
示例3: testSize
import jason.asSyntax.ListTermImpl; //导入依赖的package包/类
public void testSize() {
assertEquals(l1.size(), 3);
assertEquals(l2.size(), 2);
assertEquals(l3.size(), 1);
assertEquals(l4.size(), 3);
assertEquals(l5.size(), 1);
ListTerm l = new ListTermImpl();
l.add(new Structure("a"));
l.add(new Structure("a"));
l.add(new Structure("a"));
assertEquals(l.size(), 3);
assertTrue(l1.isList());
assertTrue(l2.isList());
assertTrue(l3.isList());
assertTrue(l4.isList());
assertTrue(l5.isList());
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:20,代码来源:ListTermTest.java
示例4: testGround
import jason.asSyntax.ListTermImpl; //导入依赖的package包/类
public void testGround() {
ListTerm l = ListTermImpl.parseList("[c,b,a,x,y,d]");
assertTrue(l.isGround());
l = ListTermImpl.parseList("[c,b,a,X,y,d]");
assertFalse(l.isGround());
l = ListTermImpl.parseList("[C,b,a,x,y,d]");
assertFalse(l.isGround());
l = ListTermImpl.parseList("[c,b,a,x,y,D]");
assertFalse(l.isGround());
l = ListTermImpl.parseList("[c,b,a,x,y|T]");
assertFalse(l.isGround());
l = ListTermImpl.parseList("[c|T]");
assertFalse(l.isGround());
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:18,代码来源:ListTermTest.java
示例5: testReverse
import jason.asSyntax.ListTermImpl; //导入依赖的package包/类
public void testReverse() {
ListTerm l = ListTermImpl.parseList("[]");
assertEquals(l, l.reverse());
assertFalse( l == l.reverse()); // should be cloned
assertEquals("[]",l.reverse().toString());
l = ListTermImpl.parseList("[a]");
assertEquals(l, l.reverse());
assertFalse( l == l.reverse()); // should be cloned
assertEquals("[a]",l.reverse().toString());
l = ListTermImpl.parseList("[a,b,c]");
assertEquals("[c,b,a]",l.reverse().toString());
l = ListTermImpl.parseList("[a,b,c|T]");
assertEquals("[c,b,a|T]",l.reverse().toString());
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:18,代码来源:ListTermTest.java
示例6: execute
import jason.asSyntax.ListTermImpl; //导入依赖的package包/类
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception{
if (logger == null) logger = ts.getLogger();
if(cM == null) cM = ClusterModelFactory.getModel(ts.getUserAgArch().getAgName());
Vec[] Center = cM.getCenters();
int n = cM.getNumberOfCluster();
int[] maxDist = cM.getMaxDist();
CowboyArch arch = (CowboyArch)ts.getUserAgArch();
LocalWorldModel model = arch.getModel();
ListTerm Cl = new ListTermImpl();
for (int i = 0;i<n;i++) {
Location l = Center[i].getLocation(model);
logger.info("HHHasl we have "+n+" clusters, and the "+i+"th is at ("+l.x+","+l.y+")");
Cl.add(ASSyntax.createStructure("pos", ASSyntax.createNumber(l.x),ASSyntax.createNumber(l.y)));
}
ListTerm Sizes = new ListTermImpl();
for(int i = 0;i<n;i++){
Sizes.add(ASSyntax.createNumber(maxDist[i]));
}
return un.unifies(args[0], ASSyntax.createNumber(n))
& un.unifies(args[1], Cl)
& un.unifies(args[2], Sizes);
}
开发者ID:jason-lang,项目名称:apps,代码行数:25,代码来源:getclusters.java
示例7: execute
import jason.asSyntax.ListTermImpl; //导入依赖的package包/类
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
try {
CowboyArch arch = (CowboyArch)ts.getUserAgArch();
LocalWorldModel model = arch.getModel();
if (model == null)
return false;
List<Location> locs = getCluster(model, 3, arch); //WorldModel.cowPerceptionRatio
if (args.length == 1) {
return un.unifies(args[0], new ObjectTermImpl(locs));
} else {
ListTerm r = new ListTermImpl();
ListTerm tail = r;
for (Location l: locs) {
tail = tail.append(createStructure("pos", createNumber(l.x), createNumber(l.y)));
}
return un.unifies(args[0], new ObjectTermImpl(locs)) &&
un.unifies(args[1], r);
}
} catch (Throwable e) {
ts.getLogger().log(Level.SEVERE, "cluster error: "+e, e);
}
return false;
}
开发者ID:jason-lang,项目名称:apps,代码行数:27,代码来源:cluster.java
示例8: parameterToTerm
import jason.asSyntax.ListTermImpl; //导入依赖的package包/类
public static Term parameterToTerm(Percept per, Parameter par) throws JasonException {
if (par instanceof Numeral) {
return ASSyntax.createNumber(((Numeral) par).getValue().doubleValue());
} else if (par instanceof Identifier) {
try {
Identifier i = (Identifier) par;
String a = i.getValue();
if (!Character.isUpperCase(a.charAt(0)))
return ASSyntax.parseTerm(a);
} catch (Exception e) {
}
return ASSyntax.createString(((Identifier) par).getValue());
} else if (par instanceof ParameterList) {
ListTerm list = new ListTermImpl();
ListTerm tail = list;
for (Parameter p : (ParameterList) par)
tail = tail.append(parameterToTerm(per, p));
return list;
} else if (par instanceof Function) {
return filter(per, par);
}
throw new JasonException("The type of parameter " + par + " is unknown!");
}
开发者ID:smart-pucrs,项目名称:mapc2016-pucrs,代码行数:24,代码来源:Translator.java
示例9: perceive
import jason.asSyntax.ListTermImpl; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public List<Literal> perceive() {
super.perceive();
if (!isRunning()) return null;
if (getEnvironmentAg() == null) return null;
@SuppressWarnings("rawtypes")
List percepts = null;
try {
ACLMessage askMsg = new ACLMessage(ACLMessage.QUERY_REF);
askMsg.addReceiver(environmentAID);
askMsg.setOntology(JadeEnvironment.perceptionOntology);
askMsg.setContent("getPercepts");
ACLMessage r = jadeAg.ask(askMsg);
if (r != null && r.getContent().startsWith("[")) {
percepts = ListTermImpl.parseList(r.getContent());
}
} catch (Exception e) {
logger.log(Level.SEVERE, "Error in perceive.", e);
}
return percepts;
}
开发者ID:jason-lang,项目名称:jason,代码行数:26,代码来源:JasonBridgeArch.java
示例10: testSize
import jason.asSyntax.ListTermImpl; //导入依赖的package包/类
public void testSize() {
assertEquals(l1.size(), 3);
assertEquals(l2.size(), 2);
assertEquals(l3.size(), 1);
assertEquals(l4.size(), 3);
assertEquals(l5.size(), 1);
ListTerm l = new ListTermImpl();
l.add(new Structure("a"));
l.add(new Structure("a"));
l.add(new Structure("a"));
assertEquals(l.size(), 3);
assertTrue(l1.isList());
assertTrue(l2.isList());
assertTrue(l3.isList());
assertTrue(l4.isList());
assertTrue(l5.isList());
}
开发者ID:jason-lang,项目名称:jason,代码行数:20,代码来源:ListTermTest.java
示例11: testGround
import jason.asSyntax.ListTermImpl; //导入依赖的package包/类
public void testGround() {
ListTerm l = ListTermImpl.parseList("[c,b,a,x,y,d]");
assertTrue(l.isGround());
l = ListTermImpl.parseList("[c,b,a,X,y,d]");
assertFalse(l.isGround());
l = ListTermImpl.parseList("[C,b,a,x,y,d]");
assertFalse(l.isGround());
l = ListTermImpl.parseList("[c,b,a,x,y,D]");
assertFalse(l.isGround());
l = ListTermImpl.parseList("[c,b,a,x,y|T]");
assertFalse(l.isGround());
l = ListTermImpl.parseList("[c|T]");
assertFalse(l.isGround());
}
开发者ID:jason-lang,项目名称:jason,代码行数:18,代码来源:ListTermTest.java
示例12: testReverse
import jason.asSyntax.ListTermImpl; //导入依赖的package包/类
public void testReverse() {
ListTerm l = ListTermImpl.parseList("[]");
assertEquals(l, l.reverse());
assertFalse( l == l.reverse()); // should be cloned
assertEquals("[]",l.reverse().toString());
l = ListTermImpl.parseList("[a]");
assertEquals(l, l.reverse());
assertFalse( l == l.reverse()); // should be cloned
assertEquals("[a]",l.reverse().toString());
l = ListTermImpl.parseList("[a,b,c]");
assertEquals("[c,b,a]",l.reverse().toString());
l = ListTermImpl.parseList("[a,b,c|T]");
assertEquals("[c,b,a|T]",l.reverse().toString());
}
开发者ID:jason-lang,项目名称:jason,代码行数:18,代码来源:ListTermTest.java
示例13: testRemWithList
import jason.asSyntax.ListTermImpl; //导入依赖的package包/类
public void testRemWithList() {
Unifier u = new Unifier();
BeliefBase bb = new DefaultBeliefBase();
Literal s = Literal.parseLiteral("seen(L)");
assertTrue(u.unifies(new VarTerm("L"), (Term)ListTermImpl.parseList("[a,b]")));
//System.out.println("u="+u);
s = (Literal)s.capply(u);
bb.add((Literal)s);
Literal b1 = new VarTerm("B1");
u.unifies(b1, Literal.parseLiteral("seen([a,b])"));
b1 = (Literal)b1.capply(u);
assertTrue(b1.equalsAsStructure(Literal.parseLiteral("seen([a,b])")));
assertTrue(b1.equalsAsStructure(s));
assertTrue(bb.remove(b1));
}
开发者ID:jason-lang,项目名称:jason,代码行数:17,代码来源:BeliefBaseTest.java
示例14: execute
import jason.asSyntax.ListTermImpl; //导入依赖的package包/类
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
try {
Literal pattern = (Literal)args[0];
Iterator<Literal> i = ts.getAg().getBB().getCandidateBeliefs(pattern, un);
ListTerm result = new ListTermImpl();
while (i.hasNext()) {
Literal l = i.next();
if (l.isRule()) {
if (un.clone().unifies(pattern, l)) {
l = l.copy();
l.delSources();
result.add(new StringTermImpl(l.toString()));
}
}
}
return un.unifies(args[1],result);
} catch (Exception e) {
logger.warning("Error in internal action 'get_rules'! "+e);
}
return false;
}
开发者ID:scranefield,项目名称:camel-agent,代码行数:23,代码来源:get_rules.java
示例15: addAnnotToList
import jason.asSyntax.ListTermImpl; //导入依赖的package包/类
protected Term addAnnotToList(Unifier unif, Term l, Term annot) throws JasonException {
if (l.isList()) {
ListTerm result = new ListTermImpl();
for (Term lTerm: (ListTerm)l) {
Term t = addAnnotToList( unif, lTerm, annot);
if (t != null) {
result.add(t);
}
}
return result;
} else if (l.isLiteral()) {
return ((Literal)l).forceFullLiteralImpl().copy().addAnnots(annot);
}
return l;
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:16,代码来源:add_annot.java
示例16: execute
import jason.asSyntax.ListTermImpl; //导入依赖的package包/类
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
checkArguments(args);
Term var = args[0];
LogicalFormula logExpr = (LogicalFormula)args[1];
ListTerm all = new ListTermImpl();
ListTerm tail = all;
Iterator<Unifier> iu = logExpr.logicalConsequence(ts.getAg(), un);
while (iu.hasNext()) {
tail = tail.append(var.capply(iu.next()));
}
return un.unifies(args[2], all);
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:15,代码来源:findall.java
示例17: setToList
import jason.asSyntax.ListTermImpl; //导入依赖的package包/类
private ListTerm setToList(Set<Term> set) {
ListTerm result = new ListTermImpl();
ListTerm tail = result;
for (Term t: set)
tail = tail.append(t.clone());
return result;
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:8,代码来源:setof.java
示例18: execute
import jason.asSyntax.ListTermImpl; //导入依赖的package包/类
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
checkArguments(args);
List<Term> lt = ((ListTerm)args[0]).getAsList();
Collections.shuffle(lt);
ListTerm ls = new ListTermImpl();
ls.addAll(lt);
return un.unifies(args[1], ls);
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:11,代码来源:shuffle.java
示例19: execute
import jason.asSyntax.ListTermImpl; //导入依赖的package包/类
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
checkArguments(args);
Trigger te = null;
try {
te = Trigger.tryToGetTrigger(args[0]);
} catch (ParseException e) {}
if (te == null)
throw JasonException.createWrongArgument(this,"first argument '"+args[0]+"' must follow the syntax of a trigger.");
ListTerm labels = new ListTermImpl();
ListTerm lt = new ListTermImpl();
ListTerm last = lt;
List<Option> rp = ts.relevantPlans(te);
if (rp != null) {
for (Option opt: rp) {
// remove sources (this IA is used for communication)
Plan np = (Plan)opt.getPlan().clone();
if (np.getLabel() != null)
np.getLabel().delSources();
np.setAsPlanTerm(true);
np.makeVarsAnnon();
last = last.append(np);
if (args.length == 3)
labels.add(np.getLabel());
}
}
boolean ok = un.unifies(lt, args[1]); // args[1] is a var;
if (ok && args.length == 3)
ok = un.unifies(labels, args[2]);
return ok;
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:36,代码来源:relevant_plans.java
示例20: execute
import jason.asSyntax.ListTermImpl; //导入依赖的package包/类
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
checkArguments(args);
RuntimeServicesInfraTier rs = ts.getUserAgArch().getRuntimeServices();
ListTerm ln = new ListTermImpl();
ListTerm tail = ln;
for (String a: rs.getAgentsNames()) {
tail = tail.append(new Atom(a));
}
return un.unifies(args[0], ln);
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:12,代码来源:all_names.java
注:本文中的jason.asSyntax.ListTermImpl类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论