本文整理汇总了Java中jade.lang.acl.ACLMessage.setOntology方法的典型用法代码示例。如果您正苦于以下问题:Java ACLMessage.setOntology方法的具体用法?Java ACLMessage.setOntology怎么用?Java ACLMessage.setOntology使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jade.lang.acl.ACLMessage
的用法示例。
在下文中一共展示了ACLMessage.setOntology方法的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);
}
示例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();
}
示例3: 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;
}
示例4: 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();
}
示例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;
}
}
}
示例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);
}
}
示例7: 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;
}
示例8: 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);
}
}
示例9: sendMsgAvailableMachinesRequest
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
/**
* Forwards a request for available machines to the server.cliebnt.
*/
private void sendMsgAvailableMachinesRequest() {
// --- Get the local Address of JADE ------------------------
String myPlatformAddress = myContainer.getPlatformID();
// --- Define the AgentAction -------------------------------
ClientAvailableMachinesRequest request = new ClientAvailableMachinesRequest();
Action act = new Action();
act.setActor(myContainer.getAMS());
act.setAction(request);
// --- Define receiver of the Message -----------------------
AID agentGUIAgent = new AID("server.client" + "@" + myPlatformAddress, AID.ISGUID );
//mainPlatformAgent.addAddresses(mainPlatform.getHttp4mtp());
// --- Build Message ----------------------------------------
ACLMessage msg = new ACLMessage(ACLMessage.INFORM);
msg.setSender(myContainer.getAMS());
msg.addReceiver(agentGUIAgent);
msg.setLanguage(new SLCodec().getName());
msg.setOntology(AgentGUI_DistributionOntology.getInstance().getName());
try {
msg.setContentObject(act);
} catch (IOException errCont) {
errCont.printStackTrace();
}
// --- Send message -----------------------------------------
myContainer.postMessageToLocalAgent(msg, agentGUIAgent);
}
示例10: sendMsgRemoteContainerRequest
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
/**
* This method configures and send a ACLMessage to start a new remote-Container.
*
* @param remConf the RemoteContainerConfig
* @param preventUsageOfAlreadyUsedComputers the boolean prevent usage of already used computers
* @return the name of the container
*/
private String sendMsgRemoteContainerRequest(RemoteContainerConfig remConf) {
// --- If the remote-configuration is null configure it now -
if (remConf==null) {
remConf = this.getRemoteContainerConfigAuto();
}
// --- Define the AgentAction -------------------------------
ClientRemoteContainerRequest req = new ClientRemoteContainerRequest();
req.setRemoteConfig(remConf);
Action act = new Action();
act.setActor(myContainer.getAMS());
act.setAction(req);
// --- Define receiver of the Message -----------------------
AID agentGUIAgent = new AID(Platform.BackgroundSystemAgentApplication + "@" + this.myContainer.getPlatformID(), AID.ISGUID);
// --- Build Message ----------------------------------------
ACLMessage msg = new ACLMessage(ACLMessage.INFORM);
msg.setSender(myContainer.getAMS());
msg.addReceiver(agentGUIAgent);
msg.setLanguage(new SLCodec().getName());
msg.setOntology(AgentGUI_DistributionOntology.getInstance().getName());
try {
msg.setContentObject(act);
} catch (IOException errCont) {
errCont.printStackTrace();
}
// --- Send message -----------------------------------------
myContainer.postMessageToLocalAgent(msg, agentGUIAgent);
// --- Remind, that we're waiting for this container --------
loadInfo.setNewContainer2Wait4(remConf.getJadeContainerName());
// --- Return -----------------------------------------------
return remConf.getJadeContainerName();
}
示例11: action
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public void action() {
// --- Wait for the start of the LoadMeasureAgent -----------
AgentController ageCont = null;
while (ageCont==null) {
try {
ageCont = myAgent.getContainerController().getAgent(loadAgentName);
} catch (ControllerException e1) {
block(100);
//e1.printStackTrace();
}
}
myAgent.getContentManager().registerLanguage(new SLCodec(), FIPANames.ContentLanguage.FIPA_SL0);
myAgent.getContentManager().registerOntology(JADEManagementOntology.getInstance());
AID receiver = new AID();
receiver.setLocalName(loadAgentName);
ACLMessage msg = new ACLMessage(ACLMessage.INFORM);
msg.addReceiver(receiver);
msg.setOntology(JADEManagementOntology.NAME);
msg.setLanguage(FIPANames.ContentLanguage.FIPA_SL0);
Action a = new Action();
a.setActor( receiver );
a.setAction(new ShowThreadGUI());
try {
myAgent.getContentManager().fillContent(msg,a);
} catch (Exception e) {
e.printStackTrace();
}
myAgent.send(msg);
myAgent.doDelete();
}
示例12: action
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public void action() {
// --- Wait for the start of the LoadMeasureAgent -----------
long waitTimeMax = System.currentTimeMillis() + (1000 * 7);
AgentController ageCont = null;
while (ageCont==null) {
if (System.currentTimeMillis()>=waitTimeMax) break;
try {
ageCont = myAgent.getContainerController().getAgent(loadAgentName);
} catch (ControllerException e1) {
block(100);
}
}
this.myAgent.getContentManager().registerLanguage(new SLCodec(), FIPANames.ContentLanguage.FIPA_SL0);
this.myAgent.getContentManager().registerOntology(JADEManagementOntology.getInstance());
AID receiver = new AID();
receiver.setLocalName(loadAgentName);
ACLMessage msg = new ACLMessage(ACLMessage.INFORM);
msg.addReceiver(receiver);
msg.setOntology(JADEManagementOntology.NAME);
msg.setLanguage(FIPANames.ContentLanguage.FIPA_SL0);
Action a = new Action();
a.setActor( receiver );
a.setAction( new ShowMonitorGUI() );
try {
this.myAgent.getContentManager().fillContent(msg,a);
} catch (Exception e) {
e.printStackTrace();
}
this.myAgent.send(msg);
this.myAgent.doDelete();
}
示例13: setup
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
protected void setup()
{
// Gets the board model
board = (Board) getArguments()[0];
// Positions the agent on the board
Cell house = (Cell) getArguments()[1];
myCell = new GhostCell(this, house);
board.setCell(myCell);
// Inits the control properties
houseLeft = false;
gameRunning = false;
reverseDirection = false;
moving = false;
shouldDie = false;
followingDirection = false;
currentDirection = lastDirection = null;
// Adds its behaviour
addBehaviour(new GhostLifecycleBehaviour(this, board, myCell)); // CyclicBehaviour
// Notifies game agent I'm loaded
ACLMessage message = new ACLMessage(ACLMessage.INFORM);
message.setOntology(GameVocabulary.ONTOLOGY);
message.setContent(GameVocabulary.AGENT_INITIALIZED);
message.addReceiver(new AID(Constant.GAME_AGENT_NAME, AID.ISLOCALNAME));
send(message);
}
示例14: setup
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
protected void setup()
{
// Gets the board model
board = (Board) getArguments()[0];
// Positions the agent on the board
Cell house = (Cell) getArguments()[1];
myCell = new PacmanCell(this, house);
board.setCell(myCell);
// Inits the control properties
gameRunning = false;
moving = false;
shouldDie = false;
followingDirection = false;
currentDirection = lastDirection = null;
powerupRemainingTurns = 0;
// Adds its behaviour
addBehaviour(new PacmanLifecycleBehaviour(this, board, myCell)); // CyclicBehaviour
// Notifies game agent I'm loaded
ACLMessage message = new ACLMessage(ACLMessage.INFORM);
message.setOntology(GameVocabulary.ONTOLOGY);
message.setContent(GameVocabulary.AGENT_INITIALIZED);
message.addReceiver(new AID(Constant.GAME_AGENT_NAME, AID.ISLOCALNAME));
send(message);
}
示例15: die
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
public void die()
{
shouldDie = true;
// Notifies GameAgent so the game ends
ACLMessage message = new ACLMessage(ACLMessage.INFORM);
message.setOntology(GameVocabulary.ONTOLOGY);
message.setContent(GameVocabulary.PACMAN_KILLED);
message.addReceiver(new AID(Constant.GAME_AGENT_NAME, AID.ISLOCALNAME));
send(message);
// Effectively dies
doDelete();
}