• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Agent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中jason.asSemantics.Agent的典型用法代码示例。如果您正苦于以下问题:Java Agent类的具体用法?Java Agent怎么用?Java Agent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Agent类属于jason.asSemantics包,在下文中一共展示了Agent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: tryToIncludeMindInspectorForAg

import jason.asSemantics.Agent; //导入依赖的package包/类
private boolean tryToIncludeMindInspectorForAg(String path) {
    try {
        Agent ag = registeredAgents.get(getAgNameFromPath(path));
        if (ag != null) {
            AgArch arch = ag.getTS().getUserAgArch();
            if (arch != null) {
                // should add a new conf for mindinspector, otherwise will start a new gui for the agent
                arch.getTS().getSettings().addOption(Settings.MIND_INSPECTOR,"web(cycle,html,no_history)");
                MindInspectorAgArch miArch = new MindInspectorAgArch();
                arch.insertAgArch(miArch);
                miArch.init();
                miArch.addAgState();
                return true;
            }
        }
    } catch (Exception e) { 
        e.printStackTrace();
    }
    return false;
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:21,代码来源:MindInspectorWebImpl.java


示例2: process

import jason.asSemantics.Agent; //导入依赖的package包/类
@Override
public Agent process(Pred directive, Agent outerContent, Agent innerContent) {
    try {
        Term goal = directive.getTerm(0);
        Pred subDir;
        if (directive.getArity() > 1) {
            subDir = Pred.parsePred(directive.getTerm(1).toString());
        } else {
            subDir = Pred.parsePred("bdg("+goal+")");
        }
        Directive sd = DirectiveProcessor.getDirective(subDir.getFunctor());

        // apply sub directive
        Agent newAg = sd.process((Pred)subDir, outerContent, innerContent); 
        if (newAg != null) {

            // add +!g : true <- !!g.
            newAg.getPL().add(ASSyntax.parsePlan("+!"+goal+" <- !!"+goal+"."));
            
            return newAg;
        }
    } catch (Exception e) {
        logger.log(Level.SEVERE,"Directive error.", e);
    }
    return null;
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:27,代码来源:BC.java


示例3: process

import jason.asSemantics.Agent; //导入依赖的package包/类
@Override
public Agent process(Pred directive, Agent outerContent, Agent innerContent) {
    try {
        Term goal = directive.getTerm(0);
        Term motivation = directive.getTerm(1);
        Pred subDir = Pred.parsePred("bc("+goal+")");
        //logger.fine("parameters="+goal+","+motivation+","+subDir);
        Directive sd = DirectiveProcessor.getDirective(subDir.getFunctor());

        // apply sub directive
        Agent newAg = sd.process(subDir, outerContent, innerContent); 
        if (newAg != null) {

            // add -m : true <- .succeed_goal(g).
            newAg.getPL().add(ASSyntax.parsePlan("-"+motivation+" <- .succeed_goal("+goal+")."));
            
            return newAg;
        }
    } catch (Exception e) {
        logger.log(Level.SEVERE,"Directive error.", e);
    }
    return null;
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:24,代码来源:RC.java


示例4: process

import jason.asSemantics.Agent; //导入依赖的package包/类
@Override
public Agent process(Pred directive, Agent outerContent, Agent innerContent) {
    try {
        // apply DG in the inner plans
        Agent newAg = super.process(directive, outerContent, innerContent); 
        if (newAg != null) {

            Term goal = directive.getTerm(0);

            // add -!g : true <- !!g.
            newAg.getPL().add(ASSyntax.parsePlan("-!"+goal+" <- !!"+goal+"."));
            
            return newAg;
        }
    } catch (Exception e) {
        logger.log(Level.SEVERE,"Directive error.", e);
    }
    return null;
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:20,代码来源:BDG.java


示例5: process

import jason.asSemantics.Agent; //导入依赖的package包/类
@Override
public Agent process(Pred directive, Agent outerContent, Agent innerContent) {
    try {
        Term goal = directive.getTerm(0);
        Term fail = directive.getTerm(1);
        Pred subDir = Pred.parsePred("bc("+goal+")");
        //logger.fine("parameters="+goal+","+fail+","+subDir);
        Directive sd = DirectiveProcessor.getDirective(subDir.getFunctor());

        // apply sub directive
        Agent newAg = sd.process(subDir, outerContent, innerContent); 
        if (newAg != null) {

            // add +f : true <- .fail_goal(g).
            newAg.getPL().add(ASSyntax.parsePlan("+"+fail+" <- .fail_goal("+goal+")."));
            
            return newAg;
        }
    } catch (Exception e) {
        logger.log(Level.SEVERE,"Directive error.", e);
    }
    return null;
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:24,代码来源:SMC.java


示例6: process

import jason.asSemantics.Agent; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Agent process(Pred directive, Agent outerContent, Agent innerContent) {
    if (outerContent == null)
        return null;
    try {
        String id = ((StringTerm)directive.getTerm(0)).getString();
        if (directive.getArity() == 1) {
            // it is implemented in java
            outerContent.addFunction((Class<ArithFunction>)Class.forName(id));
        } else if (directive.getArity() == 3) {
            // is is implemented in AS
            int arity = (int)((NumberTerm)directive.getTerm(1)).solve();
            String predicate = ((StringTerm)directive.getTerm(2)).getString();
            outerContent.addFunction(id, arity, predicate);
        } else {
            // error
            logger.log(Level.SEVERE, "Wrong number of arguments for register_function "+directive);
        }
    } catch (Exception e) {
        logger.log(Level.SEVERE, "Error processing directive register_function.",e);
    }
    return null;
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:25,代码来源:FunctionRegister.java


示例7: createArchs

import jason.asSemantics.Agent; //导入依赖的package包/类
/**
 * Creates the user agent architecture, default architecture is
 * jason.architecture.AgArch. The arch will create the agent that creates
 * the TS.
 */
public void createArchs(List<String> agArchClasses, String agClass, ClassParameters bbPars, String asSrc, Settings stts, RunCentralisedMAS masRunner) throws JasonException {
    try {
        this.masRunner = masRunner;
        Agent.create(this, agClass, bbPars, asSrc, stts);
        insertAgArch(this);
        
        createCustomArchs(agArchClasses);

        // mind inspector arch
        if (stts.getUserParameter(Settings.MIND_INSPECTOR) != null) {
            insertAgArch( (AgArch)Class.forName( Config.get().getMindInspectorArchClassName()).newInstance() );
            getFirstAgArch().init();
        }
        
        setLogger();
    } catch (Exception e) {
        running = false;
        throw new JasonException("as2j: error creating the agent class! - "+e.getMessage(), e);
    }
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:26,代码来源:CentralisedAgArch.java


示例8: execute

import jason.asSemantics.Agent; //导入依赖的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


示例9: testLogCons2

import jason.asSemantics.Agent; //导入依赖的package包/类
public void testLogCons2() {
    Agent ag = new Agent();
    ag.initAg();
    
    Rule r = new Rule(Literal.parseLiteral("r([],a(X),b(X,4))"), Literal.parseLiteral("true"));
    ag.getBB().add(r);

    Iterator<Unifier> iun = Literal.parseLiteral("r([],a(20),X)").logicalConsequence(ag, new Unifier());
    //assertEquals(iun.next().get("X").toString(),"b(20,4)");
    assertTrue(iun.hasNext());
    Literal result = Literal.parseLiteral("r([],a(20),X)");
    Unifier u = iun.next();
    assertTrue(u.get("X").isStructure());
    assertEquals( ((Structure)u.get("X")).getArity(), 2);
    assertEquals( ((Structure)u.get("X")).getFunctor(), "b");
    assertEquals(result.capply(u), Literal.parseLiteral("r([],a(20),b(20,4))"));
    
    iun = Literal.parseLiteral("r([],a(20),b(X,Y))").logicalConsequence(ag, new Unifier());
    u = iun.next();
    assertEquals(u.get("X"), ASSyntax.createNumber(20));
    assertEquals(u.get("Y"), ASSyntax.createNumber(4));

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


示例10: testLogConsWithAnnotsBacktracking

import jason.asSemantics.Agent; //导入依赖的package包/类
public void testLogConsWithAnnotsBacktracking() {
    Agent ag = new Agent();
    ag.initAg();

    ag.getBB().add(Literal.parseLiteral("p(10)[source(ag1),source(ag2),b,40,2]"));
    ag.getBB().add(Literal.parseLiteral("p(10)[source(ag3),source(ag2),b,40,2]"));
    ag.getBB().add(Literal.parseLiteral("p(20)[source(ag4),source(ag2),b,u,k]"));
    ag.getBB().add(Literal.parseLiteral("p(30)[source(ag5),source(ag2),40,u,k]"));

    Iterator<Unifier> iun = Literal.parseLiteral("p(Y)[source(X),b]").logicalConsequence(ag, new Unifier());
    int c = 0;
    while (iun.hasNext()) {
        iun.next();
        c++;
    }
    assertEquals(5, c);
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:18,代码来源:BeliefBaseTest.java


示例11: testBUF

import jason.asSemantics.Agent; //导入依赖的package包/类
public void testBUF() {
    Agent ag = new Agent();
    ag.initAg();
    
    ag.getBB().add(Literal.parseLiteral("a(10)[source(bob)]"));
    List<Literal> percepts = new ArrayList<Literal>();
    percepts.add(Literal.parseLiteral("a(10)"));
    percepts.add(Literal.parseLiteral("a(20)"));
    
    assertEquals(2,ag.buf(percepts));
    assertEquals(2,ag.getBB().size());

    assertEquals(0,ag.buf(new ArrayList<Literal>(percepts)));
    assertEquals(2,ag.getBB().size());
    
    percepts.remove(1); // remove a(20)
    assertEquals(1,ag.buf(new ArrayList<Literal>(percepts)));
    assertEquals(1,ag.getBB().size());

    percepts.clear();
    assertEquals(1,ag.buf(new ArrayList<Literal>(percepts)));
    assertEquals(1,ag.getBB().size());
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:24,代码来源:BeliefBaseTest.java


示例12: setUp

import jason.asSemantics.Agent; //导入依赖的package包/类
protected void setUp() throws Exception {
    super.setUp();
    
    intention1 = new Intention();
    Plan p = Plan.parse("+!g0 : true <- !g1; !g4.");
    intention1.push(new IntendedMeans(new Option(p,new Unifier()), null));
    
    p = Plan.parse("+!g1 : true <- !g2.");
    intention1.push(new IntendedMeans(new Option(p,new Unifier()), null));

    p = Plan.parse("+!g2 : true <- !g4; f;g.");
    intention1.push(new IntendedMeans(new Option(p,new Unifier()), null));
    
    p4 = Plan.parse("+!g4 : true <- h.");
    intention1.push(new IntendedMeans(new Option(p4,new Unifier()), null));

    p5 = Plan.parse("+!g5 : true <- i.");
    
    ag = new Agent();
    ag.initAg();
    ag.getPL().add(Plan.parse("-!g1 : true <- j."));
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:23,代码来源:StdLibTest.java


示例13: testFindAll

import jason.asSemantics.Agent; //导入依赖的package包/类
public void testFindAll() throws RevisionFailedException, ParseException {
    Agent ag = new Agent();
    ag.initAg();
    
    Literal l1 = Literal.parseLiteral("a(10,x)");
    assertFalse(l1.hasSource());
    ag.addBel(l1);
    ag.addBel(Literal.parseLiteral("a(20,y)"));
    ag.addBel(Literal.parseLiteral("a(30,x)"));
    assertEquals(ag.getBB().size(),3);
    
    Unifier u = new Unifier();
    Term X = ASSyntax.parseTerm("f(X)");
    Literal c = Literal.parseLiteral("a(X,x)");
    c.addAnnot(BeliefBase.TSelf);
    VarTerm L = new VarTerm("L");
    // System.out.println(ag.getPS().getAllRelevant(Trigger.parseTrigger(ste.getFunctor())));
    try {
        assertTrue((Boolean)new jason.stdlib.findall().execute(ag.getTS(), u, new Term[] { X, c, L }));
    } catch (Exception e) {
        e.printStackTrace();
    }
    ListTerm lt = (ListTerm) u.get("L");
    //System.out.println("found=" + lt);
    assertEquals(lt.size(), 2);
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:27,代码来源:StdLibTest.java


示例14: process

import jason.asSemantics.Agent; //导入依赖的package包/类
public Agent process(Pred directive, Agent outerContent, Agent innerContent) {
    try {
        Agent newAg = new Agent();
        newAg.initAg();
        // add .print(te) in the begin and end of the plan
        for (Plan p: innerContent.getPL()) {
            Literal print1 = Literal.parseLiteral(".print(\"Entering \","+p.getTrigger().getLiteral()+")");
            PlanBody b1 = new PlanBodyImpl(BodyType.internalAction, print1);
            p.getBody().add(0,b1);

            Literal print2 = Literal.parseLiteral(".print(\"Leaving \","+p.getTrigger().getLiteral()+")");
            PlanBody b2 = new PlanBodyImpl(BodyType.internalAction, print2);
            p.getBody().add(b2);

            newAg.getPL().add(p);
        }
        return newAg;
    } catch (Exception e) {
        logger.log(Level.SEVERE,"Directive error.", e);
    }
    return null;
}
 
开发者ID:jason-lang,项目名称:jason,代码行数:23,代码来源:LoggerDirective.java


示例15: tryToIncludeMindInspectorForAg

import jason.asSemantics.Agent; //导入依赖的package包/类
private boolean tryToIncludeMindInspectorForAg(String path) {
    try {
        Agent ag = registeredAgents.get(getAgNameFromPath(path));
        if (ag != null) {
            AgArch arch = ag.getTS().getUserAgArch();
            if (arch != null) {
                // should add a new conf for mindinspector, otherwise will start a new gui for the agent
                arch.getTS().getSettings().addOption(Settings.MIND_INSPECTOR,"web(cycle,html,no_history)");
                MindInspectorAgArch miArch = new MindInspectorAgArch();
                arch.insertAgArch(miArch);
                miArch.init();
                miArch.addAgState();
                return true;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}
 
开发者ID:jason-lang,项目名称:jason,代码行数:21,代码来源:MindInspectorWebImpl.java


示例16: process

import jason.asSemantics.Agent; //导入依赖的package包/类
@Override
public Agent process(Pred directive, Agent outerContent, Agent innerContent) {
    try {
        Term goal = directive.getTerm(0);
        Pred subDir;
        if (directive.getArity() > 1) {
            subDir = Pred.parsePred(directive.getTerm(1).toString());
        } else {
            subDir = Pred.parsePred("bdg("+goal+")");
        }
        Directive sd = DirectiveProcessor.getDirective(subDir.getFunctor());

        // apply sub directive
        Agent newAg = sd.process((Pred)subDir, outerContent, innerContent);
        if (newAg != null) {

            // add +!g : true <- !g.
            newAg.getPL().add(ASSyntax.parsePlan("+!"+goal+" <- !"+goal+"."));

            return newAg;
        }
    } catch (Exception e) {
        logger.log(Level.SEVERE,"Directive error.", e);
    }
    return null;
}
 
开发者ID:jason-lang,项目名称:jason,代码行数:27,代码来源:BC.java


示例17: process

import jason.asSemantics.Agent; //导入依赖的package包/类
@Override
public Agent process(Pred directive, Agent outerContent, Agent innerContent) {
    try {
        Term goal = directive.getTerm(0);
        Term motivation = directive.getTerm(1);
        Pred subDir = Pred.parsePred("bc("+goal+")");
        //logger.fine("parameters="+goal+","+motivation+","+subDir);
        Directive sd = DirectiveProcessor.getDirective(subDir.getFunctor());

        // apply sub directive
        Agent newAg = sd.process(subDir, outerContent, innerContent);
        if (newAg != null) {

            // add -m : true <- .succeed_goal(g).
            newAg.getPL().add(ASSyntax.parsePlan("-"+motivation+" <- .succeed_goal("+goal+")."));

            return newAg;
        }
    } catch (Exception e) {
        logger.log(Level.SEVERE,"Directive error.", e);
    }
    return null;
}
 
开发者ID:jason-lang,项目名称:jason,代码行数:24,代码来源:RC.java


示例18: testFindAll

import jason.asSemantics.Agent; //导入依赖的package包/类
public void testFindAll() throws RevisionFailedException, ParseException {
    Agent ag = new Agent();
    ag.initAg();

    Literal l1 = Literal.parseLiteral("a(10,x)");
    assertFalse(l1.hasSource());
    ag.addBel(l1);
    ag.addBel(Literal.parseLiteral("a(20,y)"));
    ag.addBel(Literal.parseLiteral("a(30,x)"));
    assertEquals(ag.getBB().size(),3);

    Unifier u = new Unifier();
    Term X = ASSyntax.parseTerm("f(X)");
    Literal c = Literal.parseLiteral("a(X,x)");
    c.addAnnot(BeliefBase.TSelf);
    VarTerm L = new VarTerm("L");
    // System.out.println(ag.getPS().getAllRelevant(Trigger.parseTrigger(ste.getFunctor())));
    try {
        assertTrue((Boolean)new jason.stdlib.findall().execute(ag.getTS(), u, new Term[] { X, c, L }));
    } catch (Exception e) {
        e.printStackTrace();
    }
    ListTerm lt = (ListTerm) u.get("L");
    //System.out.println("found=" + lt);
    assertEquals(lt.size(), 2);
}
 
开发者ID:jason-lang,项目名称:jason,代码行数:27,代码来源:StdLibTest.java


示例19: process

import jason.asSemantics.Agent; //导入依赖的package包/类
@Override
public Agent process(Pred directive, Agent outerContent, Agent innerContent) {
    try {
        // apply DG in the inner plans
        Agent newAg = super.process(directive, outerContent, innerContent);
        if (newAg != null) {

            Term goal = directive.getTerm(0);

            // add -!g : true <- !g.
            newAg.getPL().add(ASSyntax.parsePlan("-!"+goal+" <- !"+goal+"."));

            return newAg;
        }
    } catch (Exception e) {
        logger.log(Level.SEVERE,"Directive error.", e);
    }
    return null;
}
 
开发者ID:jason-lang,项目名称:jason,代码行数:20,代码来源:BDG.java


示例20: process

import jason.asSemantics.Agent; //导入依赖的package包/类
@Override
public Agent process(Pred directive, Agent outerContent, Agent innerContent) {
    try {
        Term goal = directive.getTerm(0);
        Term fail = directive.getTerm(1);
        Pred subDir = Pred.parsePred("bc("+goal+")");
        //logger.fine("parameters="+goal+","+fail+","+subDir);
        Directive sd = DirectiveProcessor.getDirective(subDir.getFunctor());

        // apply sub directive
        Agent newAg = sd.process(subDir, outerContent, innerContent);
        if (newAg != null) {

            // add +f : true <- .fail_goal(g).
            newAg.getPL().add(ASSyntax.parsePlan("+"+fail+" <- .fail_goal("+goal+")."));

            return newAg;
        }
    } catch (Exception e) {
        logger.log(Level.SEVERE,"Directive error.", e);
    }
    return null;
}
 
开发者ID:jason-lang,项目名称:jason,代码行数:24,代码来源:SMC.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PriceInfo类代码示例发布时间:2022-05-23
下一篇:
Java XSMessageFormatter类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap