本文整理汇总了Java中jason.asSyntax.ObjectTerm类的典型用法代码示例。如果您正苦于以下问题:Java ObjectTerm类的具体用法?Java ObjectTerm怎么用?Java ObjectTerm使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ObjectTerm类属于jason.asSyntax包,在下文中一共展示了ObjectTerm类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testObTerm
import jason.asSyntax.ObjectTerm; //导入依赖的package包/类
public void testObTerm() {
ObjectTerm term = new ObjectTermImpl("test");
assertTrue(term.equals(term));
assertTrue(new Unifier().unifies(new ObjectTermImpl("test"), new ObjectTermImpl("test")));
String string = "test";
assertTrue(new Unifier().unifies(new ObjectTermImpl(string), new ObjectTermImpl(string)));
BeliefBase base = new DefaultBeliefBase();
base.add(ASSyntax.createLiteral("test", new ObjectTermImpl("test")));
Iterator<Literal> iterator = base.getCandidateBeliefs(ASSyntax.createLiteral("test", new ObjectTermImpl("test")), new Unifier());
assertTrue(iterator != null && iterator.hasNext());
Literal result = iterator.next();
assertTrue(result.getFunctor().equals("test"));
assertTrue(result.getTerm(0).getClass().equals(ObjectTermImpl.class));
assertTrue(result.getTerm(0).equals(new ObjectTermImpl("test")));
assertFalse(iterator.hasNext());
}
示例2: execute
import jason.asSyntax.ObjectTerm; //导入依赖的package包/类
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
checkArguments(args);
Intention currentInt = ts.getC().getSelectedIntention();
ForkData fd = (ForkData) ((ObjectTerm)args[0]).getObject();
fd.toFinish--;
//System.out.println("** in join for "+currentInt.getId()+ " with "+fd);
// in the case of fork and, all intentions should be finished to continue
if (fd.isAnd) {
if (fd.toFinish == 0) {
//System.out.println("join finished!");
currentInt.peek().removeCurrentStep();
ts.getC().addIntention(currentInt);
}
} else {
// the first intention has finished, drop others
fd.intentions.remove(currentInt);
for (Intention i: fd.intentions) {
//System.out.println("drop "+i.getId());
drop_intention.dropInt(ts.getC(), i);
}
currentInt.peek().removeCurrentStep();
ts.getC().addIntention(currentInt);
}
return true;
}
示例3: execute
import jason.asSyntax.ObjectTerm; //导入依赖的package包/类
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
checkArguments(args);
Intention currentInt = ts.getC().getSelectedIntention();
ForkData fd = (ForkData) ((ObjectTerm)args[0]).getObject();
fd.toFinish--;
//System.out.println("** in join for "+currentInt.getId()+ " with "+fd);
// in the case of fork and, all intentions should be finished to continue
if (fd.isAnd) {
if (fd.toFinish == 0) {
//System.out.println("join finished!");
currentInt.peek().removeCurrentStep();
ts.getC().addIntention(currentInt);
}
} else {
// the first intention has finished, drop others
fd.intentions.remove(currentInt);
for (Intention i: fd.intentions) {
//System.out.println("drop "+i.getId());
drop_intention.dropInt(ts.getC(), i);
}
currentInt.peek().removeCurrentStep();
ts.getC().addIntention(currentInt);
}
return true;
}
示例4: execute
import jason.asSyntax.ObjectTerm; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
try {
CowboyArch arch = (CowboyArch)ts.getUserAgArch();
model = arch.getModel();
if (model == null)
return false;
Location agLoc = model.getAgPos(arch.getMyId());
if (agLoc == null) {
ts.getLogger().info("*** I have no location yet, so can not compute herd_position!");
return false;
}
// identify the formation id
Formation formation = Formation.six;
if (args[0].isNumeric()) {
int index = (int)((NumberTerm)args[0]).solve();
formation = Formation.values()[ index-1 ];
} else {
formation = Formation.valueOf(args[0].toString());
}
// get the cluster
List<Location> clusterLocs = (List<Location>)((ObjectTerm)args[1]).getObject();
// update GUI
if (arch.hasGUI())
setFormationLoc(clusterLocs, formation);
// if the return is a location for one agent
if (args.length == 4) {
Location agTarget = getAgTarget(clusterLocs, formation, agLoc);
if (agTarget != null) {
return un.unifies(args[2], new NumberTermImpl(agTarget.x)) &&
un.unifies(args[3], new NumberTermImpl(agTarget.y));
} else {
ts.getLogger().info("No target! I am at "+agLoc+" places are "+formationPlaces(clusterLocs, formation)+" cluster is "+lastCluster);
}
} else {
// return all the locations for the formation
List<Location> locs = formationPlaces(clusterLocs, formation);
if (locs != null && locs.size() > 0) {
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[2], r);
} else {
ts.getLogger().info("No possible formation! I am at "+agLoc+" places are "+formationPlaces(clusterLocs, formation));
}
}
} catch (Throwable e) {
ts.getLogger().log(Level.SEVERE, "herd_position error: "+e, e);
}
return false;
}
示例5: execute
import jason.asSyntax.ObjectTerm; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
try {
CowboyArch arch = (CowboyArch)ts.getUserAgArch();
model = arch.getModel();
if (model == null)
return false;
Location agLoc = model.getAgPos(arch.getMyId());
if (agLoc == null) {
ts.getLogger().info("*** I have no location yet, so can not compute herd_position!");
return false;
}
// identify the formation id
Formation formation = Formation.six;
if (args[0].isNumeric()) {
int index = (int)((NumberTerm)args[0]).solve();
formation = Formation.values()[ index-1 ];
} else {
formation = Formation.valueOf(args[0].toString());
}
// get the cluster
List<Location> clusterLocs = (List<Location>)((ObjectTerm)args[1]).getObject();
// update GUI
if (arch.hasGUI())
setFormationLoc(clusterLocs, formation);
// if the return is a location for one agent
if (args.length == 4) {
Location agTarget = getAgTarget(clusterLocs, formation, agLoc);
if (agTarget != null) {
return un.unifies(args[2], new NumberTermImpl(agTarget.x)) &&
un.unifies(args[3], new NumberTermImpl(agTarget.y));
} else {
ts.getLogger().info("No target! I am at "+agLoc+" places are "+formationPlaces(clusterLocs, formation)+" cluster is "+lastCluster);
}
} else {
// return all the locations for the formation
List<Location> locs = formationPlaces(clusterLocs, formation);
if (locs != null && locs.size() > 0) {
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[2], r);
} else {
ts.getLogger().info("No possible formation! I am at "+agLoc+" places are "+formationPlaces(clusterLocs, formation));
}
}
} catch (Throwable e) {
ts.getLogger().log(Level.SEVERE, "herd_position error: "+e, e);
}
return false;
}
示例6: execute
import jason.asSyntax.ObjectTerm; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
try {
CowboyArch arch = (CowboyArch)ts.getUserAgArch();
model = arch.getModel();
if (model == null)
return false;
Location agLoc = model.getAgPos(arch.getMyId());
// identify the formation id
Formation formation = Formation.six;
if (args[0].isNumeric()) {
int index = (int)((NumberTerm)args[0]).solve();
formation = Formation.values()[ index-1 ];
} else {
formation = Formation.valueOf(args[0].toString());
}
// get the cluster
List<Location> clusterLocs = (List<Location>)((ObjectTerm)args[1]).getObject();
// update GUI
if (arch.hasGUI())
setFormationLoc(clusterLocs, formation);
// if the return is a location for one agent
if (args.length == 4) {
Location agTarget = getAgTarget(clusterLocs, formation, agLoc);
if (agTarget != null) {
return un.unifies(args[2], new NumberTermImpl(agTarget.x)) &&
un.unifies(args[3], new NumberTermImpl(agTarget.y));
} else {
ts.getLogger().info("No target! I am at "+agLoc+" places are "+formationPlaces(clusterLocs, formation)+" cluster is "+lastCluster);
}
} else {
// return all the locations for the formation
List<Location> locs = formationPlaces(clusterLocs, formation);
if (locs != null && locs.size() > 0) {
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[2], r);
} else {
ts.getLogger().info("No possible formation! I am at "+agLoc+" places are "+formationPlaces(clusterLocs, formation));
}
}
} catch (Throwable e) {
ts.getLogger().log(Level.SEVERE, "herd_position error: "+e, e);
}
return false;
}