本文整理汇总了Java中jason.asSyntax.NumberTerm.solve方法的典型用法代码示例。如果您正苦于以下问题:Java NumberTerm.solve方法的具体用法?Java NumberTerm.solve怎么用?Java NumberTerm.solve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jason.asSyntax.NumberTerm
的用法示例。
在下文中一共展示了NumberTerm.solve方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import jason.asSyntax.NumberTerm; //导入方法依赖的package包/类
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] terms) throws Exception {
try {
WorldModel model = ((MinerArch)ts.getUserAgArch()).getModel();
if (model == null) {
ts.getLogger().log(Level.SEVERE, "no model to get near_least_visited!");
} else {
if (oldTarget != null && model.inGrid(oldTarget)) {
model.remove(WorldModel.TARGET, oldTarget);
}
NumberTerm x = (NumberTerm)terms[0];
NumberTerm y = (NumberTerm)terms[1];
Location t = new Location((int)x.solve(), (int)y.solve());
if (model.inGrid(t)) {
model.add(WorldModel.TARGET, t);
oldTarget = t;
}
}
return true;
} catch (Throwable e) {
ts.getLogger().log(Level.SEVERE, "jia.set_target error: "+e, e);
}
return false;
}
示例2: execute
import jason.asSyntax.NumberTerm; //导入方法依赖的package包/类
public boolean execute(TransitionSystem ts, Unifier un, Term[] terms) throws Exception {
try {
NumberTerm agx = (NumberTerm)terms[0].clone(); un.apply((Term)agx);
NumberTerm agy = (NumberTerm)terms[1].clone(); un.apply((Term)agy);
NumberTerm tox = (NumberTerm)terms[2].clone(); un.apply((Term)tox);
NumberTerm toy = (NumberTerm)terms[3].clone(); un.apply((Term)toy);
int iagx = (int)agx.solve();
int iagy = (int)agy.solve();
int itox = (int)tox.solve();
int itoy = (int)toy.solve();
return new Location(iagx,iagy).isNeigbour(new Location(itox,itoy));
} catch (Throwable e) {
e.printStackTrace();
return false;
}
}
示例3: execute
import jason.asSyntax.NumberTerm; //导入方法依赖的package包/类
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] terms) throws Exception {
try {
WorldModel model = ((MinerArch)ts.getUserAgArch()).getModel();
if (model == null) {
ts.getLogger().log(Level.SEVERE, "no model to get near_least_visited!");
} else {
if (oldTarget != null && model.inGrid(oldTarget)) {
model.remove(WorldModel.TARGET, oldTarget);
}
NumberTerm x = (NumberTerm)terms[0];
NumberTerm y = (NumberTerm)terms[1];
Location t = new Location((int)x.solve(), (int)y.solve());
if (model.inGrid(t)) {
model.add(WorldModel.TARGET, t);
oldTarget = t;
}
}
return true;
} catch (Throwable e) {
ts.getLogger().log(Level.SEVERE, "jia.set_target error: "+e, e);
}
return false;
}
示例4: execute
import jason.asSyntax.NumberTerm; //导入方法依赖的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;
}
}
示例5: execute
import jason.asSyntax.NumberTerm; //导入方法依赖的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;
}
}
示例6: execute
import jason.asSyntax.NumberTerm; //导入方法依赖的package包/类
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] terms) throws Exception {
try {
String sAction = null;
WorldModel model = ((MinerArch)ts.getUserAgArch()).getModel();
NumberTerm agx = (NumberTerm) terms[0];
NumberTerm agy = (NumberTerm) terms[1];
int iagx = (int) agx.solve();
int iagy = (int) agy.solve();
int itox = -1;
int itoy = -1;
while (!model.isFree(itox, itoy)) {
switch (rnd.nextInt(4)) {
case 0:
itox = iagx - 1;
sAction = "left";
break;
case 1:
itox = iagx + 1;
sAction = "right";
break;
case 2:
itoy = iagy - 1;
sAction = "up";
break;
case 3:
itoy = iagy + 1;
sAction = "down";
break;
}
}
return un.unifies(terms[2], new Atom(sAction));
} catch (Throwable e) {
e.printStackTrace();
return false;
}
}
示例7: execute
import jason.asSyntax.NumberTerm; //导入方法依赖的package包/类
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] terms) throws Exception {
try {
CowboyArch arch = (CowboyArch)ts.getUserAgArch();
WorldModel model = arch.getModel();
if (model == null) {
ts.getLogger().log(Level.SEVERE, "no model to get near_least_visited!");
} else {
if (oldTarget != null && model.inGrid(oldTarget)) {
model.remove(WorldModel.TARGET, oldTarget);
//if (arch.getACViewer() != null)
// arch.getACViewer().getModel().remove(WorldModel.TARGET, oldTarget);
}
NumberTerm x = (NumberTerm)terms[0];
NumberTerm y = (NumberTerm)terms[1];
Location t = new Location((int)x.solve(), (int)y.solve());
if (model.inGrid(t)) {
model.add(WorldModel.TARGET, t);
//if (arch.getACViewer() != null)
// arch.getACViewer().getModel().add(WorldModel.TARGET, t);
oldTarget = t;
}
}
return true;
} catch (Throwable e) {
ts.getLogger().log(Level.SEVERE, "jia.set_target error: "+e, e);
}
return false;
}
示例8: execute
import jason.asSyntax.NumberTerm; //导入方法依赖的package包/类
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] terms) throws Exception {
try {
CowboyArch arch = (CowboyArch)ts.getUserAgArch();
WorldModel model = arch.getModel();
if (model == null) {
ts.getLogger().log(Level.SEVERE, "no model to get near_least_visited!");
} else {
if (oldTarget != null && model.inGrid(oldTarget)) {
model.remove(WorldModel.TARGET, oldTarget);
//if (arch.getACViewer() != null)
// arch.getACViewer().getModel().remove(WorldModel.TARGET, oldTarget);
}
NumberTerm x = (NumberTerm)terms[0];
NumberTerm y = (NumberTerm)terms[1];
Location t = new Location((int)x.solve(), (int)y.solve());
if (model.inGrid(t)) {
model.add(WorldModel.TARGET, t);
//if (arch.getACViewer() != null)
// arch.getACViewer().getModel().add(WorldModel.TARGET, t);
oldTarget = t;
}
}
return true;
} catch (Throwable e) {
ts.getLogger().log(Level.SEVERE, "jia.set_target error: "+e, e);
}
return false;
}
示例9: execute
import jason.asSyntax.NumberTerm; //导入方法依赖的package包/类
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] terms) throws Exception {
try {
NumberTerm agId = (NumberTerm)terms[0];
Location oldTarget = oldTargetHM.get((int)agId.solve());
CowboyArch arch = (CowboyArch)ts.getUserAgArch();
WorldModel model = arch.getModel();
if (model == null) {
ts.getLogger().log(Level.SEVERE, "no model to get near_least_visited!");
} else {
if (oldTarget != null && model.inGrid(oldTarget)) {
model.remove(WorldModel.TARGET_OTHERS, oldTarget);
//if (arch.getACViewer() != null)
// arch.getACViewer().getModel().remove(WorldModel.TARGET, oldTarget);
}
NumberTerm x = (NumberTerm)terms[1];
NumberTerm y = (NumberTerm)terms[2];
Location t = new Location((int)x.solve(), (int)y.solve());
if (model.inGrid(t)) {
model.add(WorldModel.TARGET_OTHERS, t);
//if (arch.getACViewer() != null)
// arch.getACViewer().getModel().add(WorldModel.TARGET, t);
oldTarget = t;
}
}
if(oldTarget != null){
oldTargetHM.remove((int)agId.solve());
oldTargetHM.put((int)agId.solve(), oldTarget);
}
return true;
} catch (Throwable e) {
ts.getLogger().log(Level.SEVERE, "jia.set_target_others error: "+e, e);
}
return false;
}
示例10: execute
import jason.asSyntax.NumberTerm; //导入方法依赖的package包/类
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] terms) throws Exception {
try {
CowboyArch arch = (CowboyArch)ts.getUserAgArch();
WorldModel model = arch.getModel();
if (model == null) {
ts.getLogger().log(Level.SEVERE, "no model to get near_least_visited!");
} else {
if (oldTarget != null && model.inGrid(oldTarget)) {
model.remove(WorldModel.TARGET, oldTarget);
if (arch.getACViewer() != null)
arch.getACViewer().getModel().remove(WorldModel.TARGET, oldTarget);
}
NumberTerm x = (NumberTerm)terms[0];
NumberTerm y = (NumberTerm)terms[1];
Location t = new Location((int)x.solve(), (int)y.solve());
if (model.inGrid(t)) {
model.add(WorldModel.TARGET, t);
if (arch.getACViewer() != null)
arch.getACViewer().getModel().add(WorldModel.TARGET, t);
oldTarget = t;
}
}
return true;
} catch (Throwable e) {
ts.getLogger().log(Level.SEVERE, "jia.set_target error: "+e, e);
}
return false;
}
示例11: execute
import jason.asSyntax.NumberTerm; //导入方法依赖的package包/类
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] terms) throws Exception {
try {
String sAction = null;
WorldModel model = WorldModel.get();
NumberTerm agx = (NumberTerm) terms[0];
NumberTerm agy = (NumberTerm) terms[1];
int iagx = (int) agx.solve();
int iagy = (int) agy.solve();
int itox = -1;
int itoy = -1;
while (!model.isFree(itox, itoy)) {
switch (rnd.nextInt(4)) {
case 0:
itox = iagx - 1;
sAction = "left";
break;
case 1:
itox = iagx + 1;
sAction = "right";
break;
case 2:
itoy = iagy - 1;
sAction = "up";
break;
case 3:
itoy = iagy + 1;
sAction = "down";
break;
}
}
return un.unifies(terms[2], new Atom(sAction));
} catch (Throwable e) {
e.printStackTrace();
return false;
}
}
示例12: execute
import jason.asSyntax.NumberTerm; //导入方法依赖的package包/类
public boolean execute(TransitionSystem ts, Unifier un, Term[] terms) throws Exception {
try {
String sAction = "skip";
WorldModel model = WorldModel.get();
NumberTerm agx = (NumberTerm)terms[0].clone(); un.apply((Term)agx);
NumberTerm agy = (NumberTerm)terms[1].clone(); un.apply((Term)agy);
NumberTerm tox = (NumberTerm)terms[2].clone(); un.apply((Term)tox);
NumberTerm toy = (NumberTerm)terms[3].clone(); un.apply((Term)toy);
int iagx = (int)agx.solve();
int iagy = (int)agy.solve();
int itox = (int)tox.solve();
int itoy = (int)toy.solve();
if (itox < model.getWidth() && itoy < model.getHeight()) {
AEstrela searchAlg = new AEstrela();
searchAlg.setQuieto(true);
searchAlg.setMaxAbertos(1000);
//System.out.println("-- from "+iagx+","+iagy+" to "+tox+","+toy);
Nodo solution = searchAlg.busca(new MinerState(new Location(iagx, iagy), new Location(itox, itoy), model, "initial"));
if (solution == null) {
solution = searchAlg.getTheBest();
}
Nodo root = solution;
Estado prev1 = null;
Estado prev2 = null;
while (root != null) {
prev2 = prev1;
prev1 = root.getEstado();
root = root.getPai();
}
if (prev2 != null) {
//System.out.println("-- "+solution.montaCaminho());
sAction = ((MinerState)prev2).op;
}
}
return un.unifies(terms[4], new Term(sAction));
} catch (Throwable e) {
e.printStackTrace();
return false;
}
}
示例13: execute
import jason.asSyntax.NumberTerm; //导入方法依赖的package包/类
public boolean execute(TransitionSystem ts, Unifier un, Term[] terms) throws Exception {
try {
model = getClimaArch(ts).getModel();
NumberTerm agx = (NumberTerm)terms[0].clone(); un.apply((Term)agx);
NumberTerm agy = (NumberTerm)terms[1].clone(); un.apply((Term)agy);
NumberTerm tox = (NumberTerm)terms[2].clone(); un.apply((Term)tox);
NumberTerm toy = (NumberTerm)terms[3].clone(); un.apply((Term)toy);
int iagx = (int)agx.solve();
int iagy = (int)agy.solve();
itox = (int)tox.solve();
itoy = (int)toy.solve();
AEstrela searchAlg = new AEstrela();
searchAlg.setQuieto(true);
//searchAlg.setMaxF(20);
//System.out.println("-- from "+iagx+","+iagy+" to "+tox+","+toy);
Nodo solution = searchAlg.busca(new MinerState(iagx, iagy, this, "initial"));
//if (solution == null) {
// solution = searchAlg.getTheBest();
//}
Nodo root = solution;
Estado prev1 = null;
Estado prev2 = null;
while (root != null) {
prev2 = prev1;
prev1 = root.getEstado();
root = root.getPai();
}
String sAction = "skip";
if (prev2 != null) {
//System.out.println("-- "+solution.montaCaminho());
sAction = ((MinerState)prev2).op;
}
/*
Term action;
if (iagx < itox) {
action = new Term("right");
} else if (iagx > itox) {
action = new Term("left");
} else if (iagy < itoy) {
action = new Term("down");
} else {
action = new Term("up");
}
*/
return un.unifies(terms[4], new Term(sAction));
} catch (Throwable e) {
e.printStackTrace();
return false;
}
}