本文整理汇总了Java中jason.asSemantics.TransitionSystem类的典型用法代码示例。如果您正苦于以下问题:Java TransitionSystem类的具体用法?Java TransitionSystem怎么用?Java TransitionSystem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TransitionSystem类属于jason.asSemantics包,在下文中一共展示了TransitionSystem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import jason.asSemantics.TransitionSystem; //导入依赖的package包/类
public void run() {
TransitionSystem ts = getTS();
while (running) {
if (ts.getSettings().isSync()) {
waitSyncSignal();
reasoningCycle();
boolean isBreakPoint = false;
try {
isBreakPoint = ts.getC().getSelectedOption().getPlan().hasBreakpoint();
if (logger.isLoggable(Level.FINE)) logger.fine("Informing controller that I finished a reasoning cycle "+getCycleNumber()+". Breakpoint is " + isBreakPoint);
} catch (NullPointerException e) {
// no problem, there is no sel opt, no plan ....
}
informCycleFinished(isBreakPoint, getCycleNumber());
} else {
incCycleNumber();
reasoningCycle();
if (ts.canSleep())
sleep();
}
}
logger.fine("I finished!");
}
示例2: execute
import jason.asSemantics.TransitionSystem; //导入依赖的package包/类
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
checkArguments(args);
Term source = BeliefBase.ASelf;
if (args.length > 1)
source = args[1];
boolean before = false;
if (args.length > 2)
before = args[2].toString().equals("begin");
if (args[0].isList()) { // arg[0] is a list of strings
for (Term t: (ListTerm) args[0]) {
ts.getAg().getPL().add( transform2plan(t), source, before);
}
} else { // args[0] is a plan
ts.getAg().getPL().add( transform2plan(args[0]), source, before);
}
if (ts.getAg().getPL().hasMetaEventPlans())
ts.addGoalListener(new GoalListenerForMetaEvents(ts));
return true;
}
示例3: execute
import jason.asSemantics.TransitionSystem; //导入依赖的package包/类
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
checkArguments(args);
// try to get the intention from the "body"
Intention i = ts.getC().getSelectedIntention();
if (i == null) {
// try to get the intention from the event
Event evt = ts.getC().getSelectedEvent();
if (evt != null)
i = evt.getIntention();
}
if (i != null)
return un.unifies(i.getAsTerm(), args[0]);
else
return false;
}
示例4: execute
import jason.asSemantics.TransitionSystem; //导入依赖的package包/类
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
checkArguments(args);
if (args[0].isList()) {
// list reverse
if (!args[1].isVar() && !args[1].isList())
throw JasonException.createWrongArgument(this,"last argument '"+args[1]+"' must be a list or a variable.");
return un.unifies(((ListTerm)args[0]).reverse(), args[1]);
} else {
// string reverse
if (!args[1].isVar() && !args[1].isString())
throw JasonException.createWrongArgument(this,"last argument '"+args[1]+"' must be a string or a variable.");
String vl = args[0].toString();
if (args[0].isString())
vl = ((StringTerm)args[0]).getString();
return un.unifies(new StringTermImpl(new StringBuilder(vl).reverse().toString()), args[1]);
}
}
示例5: execute
import jason.asSemantics.TransitionSystem; //导入依赖的package包/类
@Override
public Object execute(final TransitionSystem ts, final Unifier un, final Term[] args) throws Exception {
checkArguments(args);
if (args.length == 1) {
return un.unifies(args[0], new NumberTermImpl(random.nextDouble()));
} else {
final int max = (int)((NumberTerm)args[1]).solve();
return new Iterator<Unifier>() {
int n = 0;
// we always have a next random number
public boolean hasNext() {
return (n < max || max == 0) && ts.getUserAgArch().isRunning();
}
public Unifier next() {
Unifier c = un.clone();
c.unifies(args[0], new NumberTermImpl(random.nextDouble()));
n++;
return c;
}
public void remove() {}
};
}
}
示例6: dropIntention
import jason.asSemantics.TransitionSystem; //导入依赖的package包/类
public int dropIntention(Intention i, Trigger g, TransitionSystem ts, Unifier un) throws JasonException {
if (i != null && i.dropGoal(g, un)) {
if (ts.hasGoalListener())
for (GoalListener gl: ts.getGoalListeners())
gl.goalFinished(g, FinishStates.achieved);
// continue the intention
if (!i.isFinished()) { // could be finished after i.dropGoal() !!
if (ts.getC().getSelectedIntention() != i) // if i is not the current intention, remove
i.peek().removeCurrentStep();
ts.applyClrInt(i);
return 1;
} else {
ts.applyClrInt(i);
return 3;
}
}
return 0;
}
示例7: execute
import jason.asSemantics.TransitionSystem; //导入依赖的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;
}
示例8: execute
import jason.asSemantics.TransitionSystem; //导入依赖的package包/类
@Override
public Object execute(TransitionSystem ts, final Unifier un, final Term[] args) throws Exception {
checkArguments(args);
// case 1, no vars
if (!args[0].isVar() && args[1].isString()) {
return args[0].toString().equals( ((StringTerm)args[1]).getString() );
}
// case 2, second is var
if (!args[0].isVar() && args[1].isVar()) {
return un.unifies(new StringTermImpl(args[0].toString()), args[1]);
}
// case 3, first is var
if (args[0].isVar() && args[1].isString()) {
return un.unifies(args[0], ASSyntax.parseTerm( ((StringTerm)args[1]).getString() ));
}
throw new JasonException("invalid case of term2string");
}
示例9: execute
import jason.asSemantics.TransitionSystem; //导入依赖的package包/类
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
checkArguments(args);
ListTerm list = (ListTerm)args[0];
if (list.isEmpty()) {
return false;
}
Iterator<Term> i = list.iterator();
Term min = i.next();
while (i.hasNext()) {
Term t = i.next();
if (compare(min,t)) {
min = t;
}
}
return un.unifies(args[1], min.clone());
}
示例10: execute
import jason.asSemantics.TransitionSystem; //导入依赖的package包/类
@Override public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
checkArguments(args);
Agent ag = ts.getAg();
Pred inc = new Pred(ns, "include");
inc.addTerms(args);
Agent result = ((Include)DirectiveProcessor.getDirective("include")).process(
inc,
ag,
null);
ag.importComponents(result);
ag.addInitialBelsInBB();
ag.addInitialGoalsInTS();
return true;
}
示例11: execute
import jason.asSemantics.TransitionSystem; //导入依赖的package包/类
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] terms) throws Exception{
try {
boolean result = false;
int iagx = (int)((NumberTerm)terms[0]).solve();//Atual
int iagy = (int)((NumberTerm)terms[1]).solve();//Atual
String dir = terms[2].toString();
if(dir.equals("up")) {
result = (un.unifies(terms[3], new Atom(String.valueOf(iagx))) && un.unifies(terms[4], new Atom(String.valueOf(1))));
}else if(dir.equals("down")) {
result = (un.unifies(terms[3], new Atom(String.valueOf(iagx))) && un.unifies(terms[4], new Atom(String.valueOf(48))));
}else if(dir.equals("left")) {
result = (un.unifies(terms[3], new Atom(String.valueOf(1))) && un.unifies(terms[4], new Atom(String.valueOf(iagy))));
}else if(dir.equals("right")) {
result = (un.unifies(terms[3], new Atom(String.valueOf(48))) && un.unifies(terms[4], new Atom(String.valueOf(iagy))));
}
return result;
}catch(Throwable e) {
e.printStackTrace();
return false;
}
}
示例12: execute
import jason.asSemantics.TransitionSystem; //导入依赖的package包/类
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
checkArguments(args);
if (args[0].isNumeric() && args[1].isString()) {
return un.unifies(args[2], deleteFromString((int)((NumberTerm)args[0]).solve(),(StringTerm)args[1]));
}
if (args[0].isNumeric() && args[1].isList()) {
return un.unifies(args[2], deleteFromList((int)((NumberTerm)args[0]).solve(),(ListTerm)args[1]));
}
if (args[0].isString() && args[1].isString()) {
return un.unifies(args[2], deleteFromString((StringTerm)args[0],(StringTerm)args[1]));
}
if (args[0].isString()) { // consider arg[1] as string
return un.unifies(args[2], deleteFromString((StringTerm)args[0], new StringTermImpl(args[1].toString())));
}
// first element as term
if (args[1].isList()) {
return un.unifies(args[2], deleteFromList(args[0],(ListTerm)args[1], un.clone()));
}
throw new JasonException("Incorrect use of the internal action '.delete' (see documentation).");
}
示例13: getTS
import jason.asSemantics.TransitionSystem; //导入依赖的package包/类
public TransitionSystem getTS() {
if (ts != null)
return ts;
if (successor != null)
return successor.getTS();
return null;
}
示例14: execute
import jason.asSemantics.TransitionSystem; //导入依赖的package包/类
@Override public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
if (args.length>0 && args[0].isNumeric()) {
NumberTerm n = (NumberTerm)args[0];
switch ((int)n.solve()) {
case 0: ts.getLogger().setLevel(Level.SEVERE); break;
case 1: ts.getLogger().setLevel(Level.INFO); break;
case 2: ts.getLogger().setLevel(Level.FINE); System.out.println("*****");break;
}
return true;
} else {
return false;
}
}
示例15: execute
import jason.asSemantics.TransitionSystem; //导入依赖的package包/类
@Override public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
for (VarTerm v : un) {
//if (! v.getFunctor().equals("Cmd__TR"))
ts.getLogger().info(v+"="+un.get(v));
}
ts.getLogger().info("done");
return true;
}