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

Java ACLMessage类代码示例

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

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



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

示例1: handleGameEnd

import jade.lang.acl.ACLMessage; //导入依赖的package包/类
private void handleGameEnd()
{
    // If the game still has remaining ghosts and collectibles,
    //  Pacman still didn't won the game
    int remainingGhosts = (int) board.getGhosts()
                                    .stream()
                                    .filter(ghost -> !ghost.isShouldDie())
                                    .count();
    
    if (0 < remainingGhosts && board.hasRemainingCollectibles())
    {
        return;
    }

    // Else, informs Game agent the game has been won (and should end)
    ACLMessage message = new ACLMessage(ACLMessage.INFORM);
    message.setOntology(GameVocabulary.ONTOLOGY);
    message.setContent(GameVocabulary.END_PACMAN_WINS);
    message.addReceiver(new AID(Constant.GAME_AGENT_NAME, AID.ISLOCALNAME));
    myAgent.send(message);
}
 
开发者ID:wguilen,项目名称:pacman-mas,代码行数:22,代码来源:PacmanMovementBehaviour.java


示例2: die

import jade.lang.acl.ACLMessage; //导入依赖的package包/类
public void die()
{
    // Marks the ghost for dying
    setShouldDie(true);
    
    // Notifies other ghosts so they can run
    ACLMessage message = new ACLMessage(ACLMessage.INFORM);
    message.setOntology(GhostVocabulary.ONTOLOGY);
    message.setContent(GhostVocabulary.THE_MOTHERFUCKER_KILLED_ME);
    board.getGhosts()
            .stream()
            .filter(ghost -> !ghost.equals(this))
            .forEach(ghost -> message.addReceiver(ghost.getAID()));
    send(message);
    
    // Notifies GameAgent I'm dead
    message.clearAllReceiver();
    message.setOntology(GameVocabulary.ONTOLOGY);
    message.setContent(GameVocabulary.GHOST_KILLED);
    message.addReceiver(new AID(Constant.GAME_AGENT_NAME, AID.ISLOCALNAME));
    send(message);
    
    // Effectively dies
    doDelete();
}
 
开发者ID:wguilen,项目名称:pacman-mas,代码行数:26,代码来源:GhostAgent.java


示例3: informAgsEnvironmentChanged

import jade.lang.acl.ACLMessage; //导入依赖的package包/类
public void informAgsEnvironmentChanged(Collection<String> agentsToNotify) {
    try {
        if (agentsToNotify == null) {
            informAgsEnvironmentChanged();
        } else {
            ACLMessage m = new ACLMessage(ACLMessage.INFORM);
            m.setContent("environmentChanged");
            for (String ag: agentsToNotify) {
                m.addReceiver(new AID(ag, AID.ISLOCALNAME));
            }
            send(m);
        }
    } catch (Exception e) {
        logger.log(Level.SEVERE, "Error sending notifyEvents ", e);
    }
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:17,代码来源:JadeEnvironment.java


示例4: perceive

import jade.lang.acl.ACLMessage; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public List<Literal> perceive() {
    if (!isRunning()) return null;
    if (getEnvironmentAg() == null) return null;
    
    @SuppressWarnings("rawtypes")
    List percepts = null;
    try {
        ACLMessage askMsg = new ACLMessage(ACLMessage.QUERY_REF);
        askMsg.addReceiver(environmentAID);
        askMsg.setOntology(JadeEnvironment.perceptionOntology);
        askMsg.setContent("getPercepts");
        ACLMessage r = jadeAg.ask(askMsg);
        if (r != null && r.getContent().startsWith("[")) {
            percepts = ListTermImpl.parseList(r.getContent());
        }
    } catch (Exception e) {
        logger.log(Level.SEVERE, "Error in perceive.", e);
    }
    
    return percepts;
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:24,代码来源:JasonBridgeArch.java


示例5: action

import jade.lang.acl.ACLMessage; //导入依赖的package包/类
@Override
public void action() {

	myAgent.getContentManager().registerLanguage(new SLCodec(), FIPANames.ContentLanguage.FIPA_SL0);
	myAgent.getContentManager().registerOntology(JADEManagementOntology.getInstance());

	ACLMessage msg = new ACLMessage(ACLMessage.REQUEST);
	msg.addReceiver(myAgent.getDefaultDF());
	msg.setOntology(JADEManagementOntology.NAME);
	msg.setLanguage(FIPANames.ContentLanguage.FIPA_SL0);
	msg.setProtocol(FIPANames.InteractionProtocol.FIPA_REQUEST);
	Action a = new Action();
	a.setActor( myAgent.getDefaultDF() );
	a.setAction( new ShowGui() );
	try {
		myAgent.getContentManager().fillContent(msg,a);
	} catch (Exception e) {
		e.printStackTrace();
	}
	myAgent.send(msg);
	myAgent.doDelete();
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:23,代码来源:ShowDFBehaviour.java


示例6: recycle

import jade.lang.acl.ACLMessage; //导入依赖的package包/类
private void recycle()
{
    if (!((GameAgent) myAgent).isTurnComplete())
    {
        if (Constant.DEBUG)
        {
            System.out.println("ResendTimeout is " + ResendTimeout);
        }
        
        if (0 == --ResendTimeout)
        {
            System.out.println("Resending move order...");
            
            ACLMessage message = new ACLMessage(ACLMessage.REQUEST);
            message.setOntology(GameVocabulary.ONTOLOGY);
            message.setContent(GameVocabulary.MOVE_YOUR_BODY);
    
            ((GameAgent) myAgent).getAgentsToMove().forEach(agent -> message.addReceiver(agent));
            myAgent.send(message);
            
            ResendTimeout = Constant.GAME_RESEND_MOVE_ORDER_TIMEOUT;
        }
    }
}
 
开发者ID:wguilen,项目名称:pacman-mas,代码行数:25,代码来源:GameMovementBehaviour.java


示例7: adviceNextGhost

import jade.lang.acl.ACLMessage; //导入依赖的package包/类
protected void adviceNextGhost()
{
    // Selects the next ghost (if any) to leave the house and sends it a message
    List<GhostAgent> nextGhosts = new ArrayList<>(); // Just for a hack
    board.getGhosts().stream().filter((ghost)
            -> (!ghost.equals(myAgent)) && !ghost.isHouseLeft() && nextGhosts.isEmpty()).forEachOrdered((ghost) ->
    {
        Coord2D position = ghost.getBoardCell().getPosition();
        for (Direction direction : Direction.values())
        {
            Cell nearCell = board.getCell(new Coord2D(position.x + direction.xInc, position.y + direction.yInc));
            if (nearCell.getType() == CellType.GHOST_HOUSE)
            {
                // Mounts the message and sends it to the next ghost to leave the house
                ACLMessage nextGhostMessage = new ACLMessage(ACLMessage.INFORM);
                nextGhostMessage.setOntology(GhostVocabulary.ONTOLOGY);
                nextGhostMessage.setContent(GhostVocabulary.LEAVE_THE_HOUSE);
                nextGhostMessage.addReceiver(ghost.getAID());
                myAgent.send(nextGhostMessage);

                nextGhosts.add(ghost); // It's added an element to nextGhosts just to break the forEachOrdered()
            }
        }
    });
}
 
开发者ID:wguilen,项目名称:pacman-mas,代码行数:26,代码来源:GhostLeaveHouseBehaviour.java


示例8: processExecutionControlOntologyMsg

import jade.lang.acl.ACLMessage; //导入依赖的package包/类
boolean processExecutionControlOntologyMsg() {
    ACLMessage m = receive(ts);
    if (m != null) {
        // send the agent state
        ACLMessage r = m.createReply();
        r.setPerformative(ACLMessage.INFORM);
        try {
            Document agStateDoc = jasonBridgeAgArch.getTS().getAg().getAgState();
            r.setContentObject((Serializable)agStateDoc);
            send(r);
        } catch (Exception e) {
            logger.log(Level.SEVERE, "Error sending message " + r, e);
        }            
    }
    
    m = receive(tc);
    if (m != null) {
        int cycle = Integer.parseInt(m.getUserDefinedParameter("cycle"));
        logger.fine("new cycle: "+cycle);
        jasonBridgeAgArch.setCycleNumber(cycle);
        return true;
    }
    return false;
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:25,代码来源:JadeAgArch.java


示例9: aclToKqml

import jade.lang.acl.ACLMessage; //导入依赖的package包/类
public static String aclToKqml(ACLMessage m) {
    switch(m.getPerformative()) {
    case ACLMessage.INFORM: return "tell"; 
    case ACLMessage.QUERY_REF: return "askOne";
    case ACLMessage.REQUEST: return "achieve";
    /*case UNTELL: return "untell";
    case UNACHIEVE: return "unachieve";
    case ASKALL: return "askAll";
    case ASKHOW: return "askHow";
    case TELLHOW: return "tellHow";
    case UNTELLHOW: return "untellHow";*/
    case ACLMessage.INFORM_REF: 
        String kp = m.getUserDefinedParameter("kqml-performative");
        if (kp != null) {
            return kp;
        }
        break;
    }
    return ACLMessage.getPerformative(m.getPerformative()).toLowerCase().replaceAll("-", "_");    
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:21,代码来源:JadeAg.java


示例10: informAllAgsToPerformCycle

import jade.lang.acl.ACLMessage; //导入依赖的package包/类
public void informAllAgsToPerformCycle(final int cycle) {
    addBehaviour(new OneShotBehaviour() {
        public void action() {
            try {
                logger.fine("Sending performCycle "+cycle+" to all agents.");
                ACLMessage m = new ACLMessage(ACLMessage.INFORM);
                m.setOntology(controllerOntology);
                addAllAgsAsReceivers(m);
                m.setContent("performCycle");
                m.addUserDefinedParameter("cycle", String.valueOf(cycle));
                send(m);
            } catch (Exception e) {
                logger.log(Level.SEVERE, "Error in informAllAgsToPerformCycle", e);
            }
        }
    });
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:18,代码来源:JadeExecutionControl.java


示例11: act

import jade.lang.acl.ACLMessage; //导入依赖的package包/类
@Override
public void act(ActionExec action) { //, List<ActionExec> feedback) {
    if (!isRunning()) return;
    if (getEnvironmentAg() == null) return;
    
    try {
        Term acTerm = action.getActionTerm();
        logger.fine("doing: " + acTerm);

        String rw  = "id"+jadeAg.incReplyWithId();
        ACLMessage m = new ACLMessage(ACLMessage.REQUEST);
        m.addReceiver(environmentAID);
        m.setOntology(JadeEnvironment.actionOntology);
        m.setContent(acTerm.toString());
        m.setReplyWith(rw);
        myPA.put(rw, action); 
        jadeAg.send(m);
    } catch (Exception e) {
        logger.log(Level.SEVERE, "Error sending action " + action, e);
    }
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:22,代码来源:JasonBridgeArch.java


示例12: isActionFeedback

import jade.lang.acl.ACLMessage; //导入依赖的package包/类
boolean isActionFeedback(ACLMessage m) {
    // check if there are feedbacks on requested action executions
    if (m.getOntology() != null && m.getOntology().equals(JadeEnvironment.actionOntology)) {
        String irt = m.getInReplyTo();
        if (irt != null) {
            ActionExec a = myPA.remove(irt);
            // was it a pending action?
            if (a != null) {
                if (m.getContent().equals("ok")) {
                    a.setResult(true);
                } else {
                    a.setResult(false);
                }
                actionExecuted(a);
            } else {
                logger.log(Level.SEVERE, "Error: received feedback for an Action that is not pending. The message is "+m);
            }
        }
        return true;
    }
    return false;
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:23,代码来源:JasonBridgeArch.java


示例13: action

import jade.lang.acl.ACLMessage; //导入依赖的package包/类
public void action() {
     ResultsAgent a = (ResultsAgent)myAgent;
     
      // Send result before closing down
     ACLMessage msg = new ACLMessage(ACLMessage.INFORM);
     msg.setSender(a.getAID());
     msg.addReceiver(new AID(SendTo, false));
     try {
         Object[] oMsg=new Object[3];
         oMsg[0] = ID;
         oMsg[1] = bText1;
         oMsg[2] = bText2;
         
         msg.setContentObject(oMsg);
     } catch (IOException ex) {
         System.err.println("Cannot add result to message. Sending empty message.");
         ex.printStackTrace(System.err);
     }
     
     a.send(msg);        
}
 
开发者ID:ayushoriginal,项目名称:Ngram-Graphs,代码行数:22,代码来源:ResultsAgent.java


示例14: action

import jade.lang.acl.ACLMessage; //导入依赖的package包/类
/** Actually sends the result to the dispatching agent.
  */
 public void action() {
     synchronized (myAgent) {
         NGramDocumentComparatorAgent a = (NGramDocumentComparatorAgent)myAgent;
     
          // Send result before closing down
         ACLMessage msg = new ACLMessage(ACLMessage.INFORM);
         msg.setSender(a.getAID());
         msg.addReceiver(a.ResultConsumer);
         try {
             msg.setContentObject(Result);
         } catch (IOException ex) {
             System.err.println("Cannot add result to message. Sending empty message.");
             ex.printStackTrace(System.err);
         }

         a.send(msg);
     }
     
}
 
开发者ID:ayushoriginal,项目名称:Ngram-Graphs,代码行数:22,代码来源:NGramDocumentComparatorAgent.java


示例15: setup

import jade.lang.acl.ACLMessage; //导入依赖的package包/类
public void setup() {
    @SuppressWarnings("unchecked")
    final List<ACLMessage> l = (List<ACLMessage>)getArguments()[0];
    addBehaviour(new jade.core.behaviours.CyclicBehaviour() {          
        public void action() {
            System.out.println(" Trying... ");
            ACLMessage m = receive();
            if(m != null) {
                System.out.println(" received "+m);
                l.add(m);
            } else { 
                block();
            }
        }
    });
}
 
开发者ID:jason-lang,项目名称:apps,代码行数:17,代码来源:Snooper.java


示例16: action

import jade.lang.acl.ACLMessage; //导入依赖的package包/类
@Override
public void action() {
    MessageTemplate mt = MessageTemplate.MatchPerformative(ACLMessage.CFP);
    ACLMessage msg = myAgent.receive();

    if (msg != null) {
        parseContent(msg.getContent());

        ACLMessage reply = msg.createReply();
        int bid;

        if (itemPrice < wallet / 4) {
            // Place a bid 5 to 10% higher than the received value
            bid = (int) (itemPrice + itemPrice * ((float) ThreadLocalRandom.current().nextInt(5, 10) / 10));

            reply.setPerformative(ACLMessage.PROPOSE);
            reply.setContent(String.valueOf(bid));
        } else {
            reply.setPerformative(ACLMessage.REFUSE);
        }

        myAgent.send(reply);
    } else {
        block();
    }
}
 
开发者ID:ohvitorino,项目名称:auctions,代码行数:27,代码来源:BidderAgent.java


示例17: processExecutionControlOntologyMsg

import jade.lang.acl.ACLMessage; //导入依赖的package包/类
boolean processExecutionControlOntologyMsg() {
    ACLMessage m = receive(ts);
    if (m != null) {
        // send the agent state
        ACLMessage r = m.createReply();
        r.setPerformative(ACLMessage.INFORM);
        try {
            Document agStateDoc = jasonBridgeAgArch.getTS().getAg().getAgState();
            r.setContentObject((Serializable)agStateDoc);
            send(r);
        } catch (Exception e) {
            logger.log(Level.SEVERE, "Error sending message " + r, e);
        }
    }

    m = receive(tc);
    if (m != null) {
        int cycle = Integer.parseInt(m.getUserDefinedParameter("cycle"));
        logger.fine("new cycle: "+cycle);
        jasonBridgeAgArch.setCycleNumber(cycle);
        return true;
    }
    return false;
}
 
开发者ID:jason-lang,项目名称:jason,代码行数:25,代码来源:JadeAgArch.java


示例18: addAllAgsAsReceivers

import jade.lang.acl.ACLMessage; //导入依赖的package包/类
public void addAllAgsAsReceivers(ACLMessage m) throws Exception {
    // get all agents' name
    DFAgentDescription template = new DFAgentDescription();
    ServiceDescription sd = new ServiceDescription();
    sd.setType("jason");
    sd.setName(JadeAgArch.dfName);
    template.addServices(sd);
    DFAgentDescription[] ans = DFService.search(this, template);
    for (int i=0; i<ans.length; i++) {
        if (!ans[i].getName().equals(getAID())) {
            m.addReceiver(ans[i].getName());
        }
    }
}
 
开发者ID:jason-lang,项目名称:jason,代码行数:15,代码来源:JadeAg.java


示例19: kqmlToACL

import jade.lang.acl.ACLMessage; //导入依赖的package包/类
public static ACLMessage kqmlToACL(String p) {
    if (p.equals("tell")) {
        return new ACLMessage(ACLMessage.INFORM);
    } else if (p.equals("askOne")) {
        return new ACLMessage(ACLMessage.QUERY_REF);
    } else if (p.equals("achieve")) {
        return new ACLMessage(ACLMessage.REQUEST);
    } else if (p.toLowerCase().equals("accept_proposal")) {
        return new ACLMessage(ACLMessage.ACCEPT_PROPOSAL);
    } else if (p.toLowerCase().equals("reject_proposal")) {
        return new ACLMessage(ACLMessage.REJECT_PROPOSAL);
    } else if (p.toLowerCase().equals("query_if")) {
        return new ACLMessage(ACLMessage.QUERY_IF);
    } else if (p.toLowerCase().equals("inform_if")) {
        return new ACLMessage(ACLMessage.INFORM_IF);            
    }
    int perf = ACLMessage.getInteger(p);
    if (perf == -1 || perf == ACLMessage.NOT_UNDERSTOOD) {
        ACLMessage m = new ACLMessage(ACLMessage.INFORM_REF);
        m.addUserDefinedParameter("kqml-performative", p);
        return m;
    }
    return new ACLMessage(perf);
}
 
开发者ID:jason-lang,项目名称:jason,代码行数:25,代码来源:JadeAg.java


示例20: aclPerformativeToKqml

import jade.lang.acl.ACLMessage; //导入依赖的package包/类
public static String aclPerformativeToKqml(ACLMessage m) {
    switch(m.getPerformative()) {
    case ACLMessage.INFORM:
        return "tell";
    case ACLMessage.QUERY_REF:
        return "askOne";
    case ACLMessage.REQUEST:
        return "achieve";
    case ACLMessage.INFORM_REF:
        String kp = m.getUserDefinedParameter("kqml-performative");
        if (kp != null) {
            return kp;
        }
        break;
    }
    return ACLMessage.getPerformative(m.getPerformative()).toLowerCase().replaceAll("-", "_");
}
 
开发者ID:jason-lang,项目名称:jason,代码行数:18,代码来源:JadeAg.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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