本文整理汇总了Java中jason.asSemantics.TransitionSystem类的典型用法代码示例。如果您正苦于以下问题:Java TransitionSystem类的具体用法?Java TransitionSystem怎么用?Java TransitionSystem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TransitionSystem类属于jason.asSemantics包,在下文中一共展示了TransitionSystem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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!");
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:24,代码来源:CentralisedAgArch.java
示例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;
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:26,代码来源:add_plan.java
示例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;
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:19,代码来源:current_intention.java
示例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]);
}
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:23,代码来源:reverse.java
示例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() {}
};
}
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:26,代码来源:random.java
示例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;
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:20,代码来源:succeed_goal.java
示例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;
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:26,代码来源:relevant_rules.java
示例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");
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:22,代码来源:term2string.java
示例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());
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:20,代码来源:min.java
示例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;
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:18,代码来源:include.java
示例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;
}
}
开发者ID:MTeixeira24,项目名称:Jasovacs_fire,代码行数:24,代码来源:get_sign_point.java
示例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).");
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:25,代码来源:delete.java
示例13: getTS
import jason.asSemantics.TransitionSystem; //导入依赖的package包/类
public TransitionSystem getTS() {
if (ts != null)
return ts;
if (successor != null)
return successor.getTS();
return null;
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:8,代码来源:AgArch.java
示例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;
}
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:14,代码来源:verbose.java
示例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;
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:9,代码来源:print_unifier.java
示例16: sense
import jason.asSemantics.TransitionSystem; //导入依赖的package包/类
protected void sense() {
TransitionSystem ts = getTS();
int i = 0;
do {
ts.sense(); // must run at least once, so that perceive() is called
} while (running && ++i < cyclesSense && !ts.canSleepSense());
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:9,代码来源:CentralisedAgArch.java
示例17: deliberate
import jason.asSemantics.TransitionSystem; //导入依赖的package包/类
protected void deliberate() {
TransitionSystem ts = getTS();
int i = 0;
while (running && i++ < cyclesDeliberate && !ts.canSleepDeliberate()) {
ts.deliberate();
}
//sumDel += i; nbDel++;
//System.out.println("running del "+(sumDel/nbDel)+"/"+cyclesDeliberate);
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:10,代码来源:CentralisedAgArch.java
示例18: act
import jason.asSemantics.TransitionSystem; //导入依赖的package包/类
protected void act() {
TransitionSystem ts = getTS();
int i = 0;
int ca = cyclesAct;
if (cyclesAct == 9999)
ca = ts.getC().getIntentions().size();
while (running && i++ < ca && !ts.canSleepAct()) {
ts.act();
}
//sumAct += i; nbAct++;
//System.out.println("running act "+(sumAct/nbAct)+"/"+ca);
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:15,代码来源:CentralisedAgArch.java
示例19: execute
import jason.asSemantics.TransitionSystem; //导入依赖的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
示例20: execute
import jason.asSemantics.TransitionSystem; //导入依赖的package包/类
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
checkArguments(args);
Calendar now = new GregorianCalendar();
return un.unifies(args[0], new NumberTermImpl(now.get(Calendar.HOUR_OF_DAY))) &&
un.unifies(args[1], new NumberTermImpl(now.get(Calendar.MINUTE))) &&
un.unifies(args[2], new NumberTermImpl(now.get(Calendar.SECOND)));
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:10,代码来源:time.java
注:本文中的jason.asSemantics.TransitionSystem类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论