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


Java ACLMessage.addReceiver方法代码示例

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


在下文中一共展示了ACLMessage.addReceiver方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例7: 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

示例8: 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

示例9: 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

示例10: perceive

import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public List<Literal> perceive() {
    super.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:jason-lang,项目名称:jason,代码行数:26,代码来源:JasonBridgeArch.java

示例11: act

import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public void act(ActionExec action) {
    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:jason-lang,项目名称:jason,代码行数:22,代码来源:JasonBridgeArch.java

示例12: receiveMessage

import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public void receiveMessage(final FrameworkMessage msg, final String messageID,
		final String inReplyToMessageID, final JadeControllerMock jade_ControllerMock) {
	final ACLMessage aclMsg = new ACLMessage(ACLMessage.INFORM);
	aclMsg.addReceiver(aid);
	aclMsg.setContent(msg.toPrettyPrintedXMLString());
	aclMsg.setConversationId("jade-controller");
	aclMsg.setReplyWith(UUID.randomUUID().toString());

	System.out
			.println("[JADE Controller Agent ] Sending message to distributed JADE Agent: "
					+ distributedSystemID
					+ " "
					+ distributedAutonomousAgentID
					+ " "
					+ distAutAgentModelID);
	jadeControllerAgent.send(aclMsg);

}
 
开发者ID:OpenSimulationSystems,项目名称:CABSF_Java,代码行数:20,代码来源:CsfDistributedJADEagentWrapper.java

示例13: action

import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public void action()
{
	removeBehaviour(OrderPicker.this.abortOrder);
	removeBehaviour(OrderPicker.this.shelfInteraction);

	log("Order complete, send INFORM to " + OrderPicker.this.currentOrderAgent.getLocalName() + "!");

	ACLMessage inform = new ACLMessage(ACLMessage.INFORM);
	inform.addReceiver(OrderPicker.this.currentOrderAgent);
	inform.setLanguage("JSON");
	inform.setProtocol("JSON");
	inform.setContent(OrderPicker.this.orderOutgoing.toString());
	send(inform);

	OrderPicker.this.itemStatus.clear();
	OrderPicker.this.shelfInfo.clear();
	OrderPicker.this.orderOutgoing = null;
	OrderPicker.this.orderOutgoing = new JSONArray();

	OrderPicker.this.isIdle = true;

	removeBehaviour(this);
}
 
开发者ID:autarchprinceps,项目名称:Multiagent-Warehouse,代码行数:25,代码来源:OrderPicker.java

示例14: action

import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public void action() {
	ACLMessage recMsg = receive(MessageTemplate.MatchPerformative(ACLMessage.INFORM));
	if(recMsg != null) {
		ACLMessage response = new ACLMessage(ACLMessage.INFORM);
		Order ordr = unfinishedOrders.get(recMsg.getSender());
		for(AID rec : ordr.requestingAgents) {
			response.addReceiver(rec);
		}
		response.setLanguage("JSON");
		StringBuilder sb = new StringBuilder("{id:");
		sb.append(ordr.id).append(",list:[");
		for(Pair<String, Integer> p : ordr.items) {
			sb.append(p.getFirst()).append(":").append(p.getSecond()).append(",");
		}
		sb.deleteCharAt(sb.length() - 1);
		sb.append("]}");
		response.setContent(sb.toString());
		System.out.println("WarehouseAgent: Sending completed order to customer: " + ordr.id);
		send(response);
	} else {
		block();
	}
}
 
开发者ID:autarchprinceps,项目名称:Multiagent-Warehouse,代码行数:25,代码来源:WarehouseAgent.java

示例15: requestOrder

import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
private void requestOrder() {

			DFAgentDescription template = new DFAgentDescription();
			ServiceDescription sd = new ServiceDescription();

			sd.setType("giveOrder");
			template.addServices(sd);

			try {
				DFAgentDescription[] result = DFService.search(myAgent,
						template);
				ACLMessage msg = new ACLMessage(ACLMessage.REQUEST);
				for (DFAgentDescription agent : result) {
					msg.addReceiver(agent.getName());

					send(msg);
				}
			} catch (FIPAException fe) {
				fe.printStackTrace();
			}
		}
 
开发者ID:ChrisQuignon,项目名称:kivasim,代码行数:22,代码来源:Picker.java


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