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


Java ACLMessage.setContent方法代码示例

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


在下文中一共展示了ACLMessage.setContent方法的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: 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

示例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包/类
@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

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

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

示例10: action

import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
public void action() {
    MessageTemplate mt = MessageTemplate.MatchPerformative(ACLMessage.CFP);
    ACLMessage msg = myAgent.receive(mt);
    if (msg != null) {
        // CFP Message received. Process it
        String title = msg.getContent();
        ACLMessage reply = msg.createReply();

        Integer price = (Integer) catalogue.get(title);
        if (price != null) {
            // The requested book is available for sale. Reply with the price
            reply.setPerformative(ACLMessage.PROPOSE);
            reply.setContent(String.valueOf(price.intValue()));
        } else {
            // The requested book is NOT available for sale.
            reply.setPerformative(ACLMessage.REFUSE);
            reply.setContent("not-available");
        }
        myAgent.send(reply);
    } else {
        block();
    }
}
 
开发者ID:jason-lang,项目名称:jason,代码行数:24,代码来源:BookSellerAgent.java

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

示例12: action

import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public void action() {
	ACLMessage message = new ACLMessage(ACLMessage.INFORM);
	message.setConversationId("BACKGROUND");
	message.addReceiver(myAgent.getSoundAgentName());
	my_data.setAction(type);
	my_data.setPath(path);

	ObjectMapper mapper = new ObjectMapper();
	StringWriter sw = new StringWriter();
	try {			
		mapper.writeValue(sw, my_data);
		message.setContent(sw.toString());				
	} catch (Exception e) {
		e.printStackTrace();
	}
	myAgent.send(message);
	System.out.println("bg message sent");
}
 
开发者ID:hukewei,项目名称:leapband,代码行数:20,代码来源:SendBgMusicBehaviour.java

示例13: action

import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public void action() {
	ObjectMapper mapper = new ObjectMapper();
	StringWriter sw = new StringWriter();
	ACLMessage message = new ACLMessage(ACLMessage.INFORM);
	try {			

		mapper.writeValue(sw, inform);
		
		message.addReceiver(aid);
		//message.setConversationId(id.toString());
		message.setConversationId("NOTE");
		message.setContent(sw.toString());				
		myAgent.send(message);
	} catch (Exception e) {

		e.printStackTrace();
	}			
}
 
开发者ID:hukewei,项目名称:leapband,代码行数:20,代码来源:SenderInformBehaviour.java

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

示例15: action

import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public void action()
{
    // If the game is not running or Pacman is marked
    //      for death, doesn't move
    if (!(                                              // If not
            ((PacmanAgent) myAgent).isGameRunning()     // ... game is running
            && !((PacmanAgent) myAgent).isShouldDie()   // ... Pacman is not marked for death
       ))
    {
        System.out.println(myAgent.getLocalName() + " cannot move!");
        
        // Replies to the Game Agent denying this behaviour
        ACLMessage reply = originMessage.createReply();
        reply.setPerformative(ACLMessage.REFUSE);
        reply.setContent(GameVocabulary.MOVED_MY_BODY);
        myAgent.send(reply);
    
        // Updates the GhostAgent state
        ((PacmanAgent) myAgent).setMoving(false);
        
        // Removes this behaviour from Pacman
        myAgent.removeBehaviour(this);
        
        return;
    }
    
    synchronized(this)
    {
        move();                 // Pacman makes a movement
        checkGhostInSamePath(); // Pacman checks if there is a ghost in the same path as it
    }
}
 
开发者ID:wguilen,项目名称:pacman-mas,代码行数:34,代码来源:PacmanMovementBehaviour.java


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