edu.udo.cs.ie.cowbots.arch
Class MassimAdapter

Package class diagram package MassimAdapter
java.lang.Object
  extended by edu.udo.cs.ie.cowbots.arch.EnvironmentAdapter
      extended by edu.udo.cs.ie.cowbots.arch.MassimAdapter

public class MassimAdapter
extends EnvironmentAdapter

Implementation of EnvionmentAdapter to connect the Cowbot MAS to Massim. It is used to receive perceptions from massim an convert them to literals used for the Cowbots beliefs, and to send the cowbots actions to massim so they can interact with the environment they 'live' in.


Field Summary
private  java.lang.String agName
           
(package private)  java.util.logging.Logger log
           
private  MassimAgent massimAgent
          Instance of an MassimAgent, wich takes part in the massim simulation.
private  int worldTime
           
 
Fields inherited from class edu.udo.cs.ie.cowbots.arch.EnvironmentAdapter
envLock, hasNewPercepts, newEndPer, newEnvPer, newSimPer, owner
 
Constructor Summary
MassimAdapter(AgArch owner, java.lang.String host, java.lang.String username, java.lang.String pass, int port)
          Creates a new instance of an massim adapter
 
Method Summary
 void act(java.lang.String action)
          Method so set the next action performed by the agent in the massim environment.
private  Literal addPerceptIdentificator(java.lang.String ident, java.lang.String id)
           
private  Literal addPerceptWithIDAndPosition(java.lang.String name, int x, int y, java.lang.String step)
          Utility functions for generating default 'ison' literals
 int getWorldTime()
           
 void processMassimPercepts(org.w3c.dom.Element percepts)
          Receives the perceptions from massim in xml format, and converts them to literals used for the Cowbots beliefs.
 void processMassimSimStart(org.w3c.dom.Element percepts)
          Called when simulation starts, receives some information about the world size.
 void processSimulationEnd(org.w3c.dom.Element perception, long currenttime)
           
 
Methods inherited from class edu.udo.cs.ie.cowbots.arch.EnvironmentAdapter
acquire, getPercepts, newEndOfSimulation, newPercepts, newSimulation, release
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

massimAgent

private MassimAgent massimAgent
Instance of an MassimAgent, wich takes part in the massim simulation.


agName

private java.lang.String agName

worldTime

private int worldTime

log

java.util.logging.Logger log
Constructor Detail

MassimAdapter

public MassimAdapter(AgArch owner,
                     java.lang.String host,
                     java.lang.String username,
                     java.lang.String pass,
                     int port)
Creates a new instance of an massim adapter

Parameters:
owner - AgentArch, to wake up the reasoning cycle with given new perceptions
host - The host massim is running on
username - The agents username
pass - The agents password
port - The port massim is listening to
Method Detail

processMassimPercepts

public void processMassimPercepts(org.w3c.dom.Element percepts)
Receives the perceptions from massim in xml format, and converts them to literals used for the Cowbots beliefs.

Parameters:
percepts - XML Root Element

processMassimSimStart

public void processMassimSimStart(org.w3c.dom.Element percepts)
Called when simulation starts, receives some information about the world size. It is used to generate beliefs for every unexplored field of the world map and to generate beliefs about the world size.

Parameters:
percepts - XML Root Element

addPerceptIdentificator

private Literal addPerceptIdentificator(java.lang.String ident,
                                        java.lang.String id)

addPerceptWithIDAndPosition

private Literal addPerceptWithIDAndPosition(java.lang.String name,
                                            int x,
                                            int y,
                                            java.lang.String step)
Utility functions for generating default 'ison' literals

Parameters:
name -
x -
y -
step -
Returns:

act

public void act(java.lang.String action)
Method so set the next action performed by the agent in the massim environment.

Specified by:
act in class EnvironmentAdapter
Parameters:
action - Action performed by the agent Possible actions are: skip, north, south, east, west, northwest, northeast, southwest, southeast

getWorldTime

public int getWorldTime()
Specified by:
getWorldTime in class EnvironmentAdapter

processSimulationEnd

public void processSimulationEnd(org.w3c.dom.Element perception,
                                 long currenttime)