当前位置: 首页>>代码示例>>Java>>正文


Java ObjectTerm类代码示例

本文整理汇总了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());

}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:22,代码来源:TermTest.java

示例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;
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:30,代码来源:join.java

示例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;
}
 
开发者ID:jason-lang,项目名称:jason,代码行数:30,代码来源:join.java

示例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;
}
 
开发者ID:jason-lang,项目名称:apps,代码行数:59,代码来源:herd_position.java

示例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;
}
 
开发者ID:jason-lang,项目名称:apps,代码行数:59,代码来源:herd_position.java

示例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;
}
 
开发者ID:jason-lang,项目名称:apps,代码行数:55,代码来源:herd_position.java


注:本文中的jason.asSyntax.ObjectTerm类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。