Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## madkit.kernel
Class AbstractAgent

    java.lang.Object
      madkit.kernel.AbstractAgent

All Implemented Interfaces:
  java.io.Serializable

Direct Known Subclasses:
  AbstractBee, AbstractPredator, Agent, Brain, DemoLauncher, Prey, SynchroScheduler, Turtle, TurtleEnvironment, WarbotEnvironment, Watcher

    public class AbstractAgent

extends java.lang.Object
implements java.io.Serializable

The main MadKit AbstractAgent class. It provides support for agent's

- Lifecycle
- Group and roles management
- Messaging
- Graphical interface
- Agent informations

The agent's behavior is intentionally not defined. It is up to the agent developer to choose an agent model or to develop his specific agent library on top of the facilities provided by MadKit. However, all agent share the same organizational view, and the basic messaging code, so integration of agent coming from different developer and having heterogeneous models is quite easy.

Agent-related methods (almost everything here) can be invoked only after registration in the kernel (i.e. after the `activate` method has been invoked on this agent). That means that you should not use any of the agent methods in constructor

Version:
  3.6 20/05/2008
Author:
  Olivier Gutknecht, Fabien Michel
See Also:
  Serialized Form

Constructor Summary
`AbstractAgent()` Default no-args constructor, which just set-up internal structures

Method Summary
`void` | `activate()` This method is initially called when the micro-kernel registers the agent.
`void` | `broadcastMessage(java.lang.String groupName, java.lang.String roleName, Message m)`
`void` | `broadcastMessage(java.lang.String communityName, java.lang.String groupName, java.lang.String roleName, Message m)` Broadcast a message to every agent having a role in a group.
`boolean` | `connectedWithCommunity(java.lang.String communityName)` returns true if the community is shared on the network
`int` | `createGroup(boolean distributed, java.lang.String groupName, java.lang.String description, GroupIdentifier theIdentifier)` Creates a new Group within the default community public.
`int` | `createGroup(boolean distributed, java.lang.String communityName, java.lang.String groupName, java.lang.String description, GroupIdentifier theIdentifier)` Creates a new Group.
`void` | `debug(java.lang.String message)` Print out debug information only if the debug flag is on.
`void` | `destroyGroup(java.lang.String communityName, java.lang.String groupName)` This method is still experimental.
`void` | `disposeMyGUI()` hide the graphical component that represents the Agent in some higher interface
`void` | `end()` This method is called by the agent micro-kernel at the end of the agent lifecycle.
`void` | `foundGroup(java.lang.String groupName)` Deprecated. As of MadKit 3.0. replaced by `createGroup(boolean,String,String,String,GroupIdentifier)`. This call is now equivalent to `createGroup(true, groupName, null, null)`.
`AgentAddress` | `getAddress()` Gets the agent's own agent address.
`AgentAddress[]` | `getAgentsWithRole(java.lang.String groupName, java.lang.String roleName)` Gets the addresses of all the agents (including this agent if present) that handle this role within this group.
`AgentAddress[]` | `getAgentsWithRole(java.lang.String communityName, java.lang.String groupName, java.lang.String roleName)` Gets the addresses of all the agents (including this agent if present) that handle this role within this group in this community.
`AgentAddress` | `getAgentWithRole(java.lang.String groupName, java.lang.String roleName)` Gets an agent that handles a given role within a group of the default MadKit community.
`AgentAddress` | `getAgentWithRole(java.lang.String communityName, java.lang.String groupName, java.lang.String roleName)` Gets an agent that handles a given role within a group of a particular community.
`java.lang.String[]` | `getAvailableCommunities()` returns the available communities
`java.lang.Object` | `getBean()` Deprecated. As of MadKit 2.0. replaced by `getGUIObject()`
`Controller` | `getController()` Returns the current controller of the agent if there is one.
`KernelAddress` | `getCurrentKernelAddress()` Returns the kernelAddress of the agency where this agent is situated...
`boolean` | `getDebug()`
`java.lang.String[]` | `getExistingGroups()` returns an array containing the names of the groups which exist in the default community.
`java.lang.String[]` | `getExistingGroups(java.lang.String communityName)` returns the names of the groups that exist in this community.
`java.lang.String[]` | `getExistingRoles(java.lang.String groupName)` returns the names of the roles that exist within this group in the default community.
`java.lang.String[]` | `getExistingRoles(java.lang.String communityName, java.lang.String groupName)` returns the names of the roles that exist in this (community,group) couple.
`java.util.Vector<java.lang.String>` | `getGroups()` Deprecated. As of MadKit 3.0. replaced by `getExistingGroups(String)`
`java.lang.Object` | `getGUIObject()` Gets the graphic component representing the agent.
`int` | `getMessageBoxSize()` Gets the number of messages in the message box
`java.lang.String[]` | `getMyGroups()` Gets the name of the groups the agent joined in the default community.
`java.lang.String[]` | `getMyGroups(java.lang.String communityName)` Gets the name of the groups the agent joined in this community.
`java.lang.String[]` | `getMyRoles(java.lang.String groupName)` Gets roles currently handled within a group of the default community.
`java.lang.String[]` | `getMyRoles(java.lang.String communityName, java.lang.String groupName)` Gets roles currently handled within a group of this community.
`java.lang.String` | `getName()` Gets the current agent patronymic name.
`java.lang.String[]` | `getRoles(java.lang.String groupName)` Deprecated. As of MadKit 3.0. replaced by `getExistingRoles(String,String)`
`boolean` | `hasGUI()` Check if a bean is running in GUI mode.
`int` | `hashCode()`
`void` | `hideMyGUI()`
`void` | `initGUI()` This method is called by the specific external graphic system (as the G-Box) to ask the agent to prepare a graphical interface.
`boolean` | `isBelongingToGroup(AgentAddress address, java.lang.String groupName)` Tell if an agent is a member of a specific group in the default community
`boolean` | `isBelongingToGroup(AgentAddress address, java.lang.String communityName, java.lang.String groupName)` Tells if an agent is a member of a specific group in a given community.
`boolean` | `isCommunity(java.lang.String communityName)` Determines if this group already exists in this community
`boolean` | `isGroup(java.lang.String groupName)` Determines if this group already exists in the default community
`boolean` | `isGroup(java.lang.String communityName, java.lang.String groupName)` Determines if this group already exists in this community
`boolean` | `isMemberOf(java.lang.String groupName)` Tells if the agent is a member of a specific group in the default community.
`boolean` | `isMemberOf(java.lang.String communityName, java.lang.String groupName)` Tells if the agent is a member of a specific group in a given community
`boolean` | `isMessageBoxEmpty()` Is there any message left to be read ?
`boolean` | `isRole(java.lang.String groupName, java.lang.String roleName)`
`boolean` | `isRole(java.lang.String communityName, java.lang.String groupName, java.lang.String roleName)`
`void` | `joinGroup(java.lang.String groupName)` Deprecated. As of MadKit 3.0. replaced by `createGroup(boolean,String,String,String,GroupIdentifier)`. This call is now equivalent to `createGroup(true, groupName, null, null)` if the group does not exist or `requestRole(groupName, "member", null)` otherwise.
`void` | `killAgent(AbstractAgent agent)` Kills another agent (or self).
`void` | `launchAgent(AbstractAgent agent, java.lang.String name, boolean gui)` This method is called in order to launch an agent from another agent.
`void` | `launchAgent(AbstractAgent agent, java.lang.String name, java.awt.Point position, java.awt.Dimension dim)` This method try to launch an agent with a GUI with the specified coordinates and dimension.
`int` | `leaveGroup(java.lang.String groupName)` Makes the agent leave a group of the default community.
`int` | `leaveGroup(java.lang.String communityName, java.lang.String groupName)` Makes the agent leave a group of a particular community.
`int` | `leaveRole(java.lang.String groupName, java.lang.String roleName)` Abandons an handled role within a group of the default community.
`int` | `leaveRole(java.lang.String communityName, java.lang.String groupName, java.lang.String roleName)` Abandons an handled role within a group of a particular community.
`Message` | `nextMessage()` Gets the first message in the queue.
`void` | `print(java.lang.String message)` Prints text information in a environment-independent way (GUI, console, ...)
`void` | `println(java.lang.String message)` Prints text information in an environment-independent way (GUI, console, ...)
`protected void` | `receiveMessage(Message m)` This method is invoked by the kernel when the agent receives a message.
`void` | `redisplayMyGUI()` try to restore the graphical component that represents the Agent in some higher interface
`void` | `requestRole(java.lang.String groupName, java.lang.String roleName)` Deprecated. As of MadKit 3.0. replaced by `requestRole(String,String,Object)`. This call is now equivalent to `requestRole(groupName, roleName, null)`.
`int` | `requestRole(java.lang.String groupName, java.lang.String roleName, java.lang.Object memberCard)` Requests a role within a group of the default community.
`int` | `requestRole(java.lang.String communityName, java.lang.String groupName, java.lang.String roleName, java.lang.Object memberCard)` Requests a role within a group of a particular community.
`void` | `restoreAgent(AbstractAgent agent)` experimental
`void` | `sendMessage(AgentAddress a, Message m)` Send a message to another agent.
`void` | `sendMessage(java.lang.String groupName, java.lang.String roleName, Message m)` Send a message to an agent having a specific role in a group of the default community
`boolean` | `sendMessage(java.lang.String communityName, java.lang.String groupName, java.lang.String roleName, Message m)` Send a message to an agent having a specific role in a group of this particular community.
`void` | `setBean(java.lang.Object theBean)` Deprecated. As of MadKit 2.0. replaced by `setGUIObject(Object)`
`void` | `setController(Controller c)` Assign a controller which will be in charge of the control of the agent's behavior
`void` | `setDebug(boolean b)` Sets the debug flag.
`void` | `setGUIObject(java.lang.Object theBean)` This method set the bean that will be used to represent the agent in a graphical environment, the agent is also registered as running in GUI mode
`void` | `setName(java.lang.String theName)` Change the current agent patronymic name.
`void` | `setOutput(java.io.Writer o)` Deprecated. As of MadKit 2.0. replaced by `setOutputWriter(Writer)`
`void` | `setOutputWriter(java.io.Writer o)` Reassigns the "standard" agent text output stream (used by method println).
`java.lang.String` | `toString()`
`void` | `windowClosing(java.awt.AWTEvent we)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### AbstractAgent

    public AbstractAgent()

  Default no-args constructor, which just set-up internal structures

Method Detail

### getController

    public Controller getController()

  Returns the current controller of the agent if there is one.

  Returns:
    the controller

### setController

    public void setController(Controller c)

  Assign a controller which will be in charge of the control of the agent's behavior

### activate

    public void activate()

  This method is initially called when the micro-kernel registers the agent. Usually a good place to set up some initial groups and roles.

  Here is a typical example (taken from the `PingPong` agent of MadKit (plugin demos)) :

  >     public void activate()
  >     {
  >             try {
  >                     createGroup(true,"ping-pong",null,null);
  >                     println ("No ping-pong group : I created one");
  >                     creator=true;
  >             } catch (OrganizationRequestException e) { // the group already exists
  >                     creator=false;
  >                     println ("A ping-pong group already exists : I will join");
  >             }
  >             requestRole("ping-pong","player",null);
  >     }

### end

    public void end()

  This method is called by the agent micro-kernel at the end of the agent lifecycle. If the the agent is killed from the outside, it is the last opportunity for the agent to cleanly shutdown its operations. Although it is "nicer" to make the agent leave its groups, the handled groups and roles are automatically leaved after this last step

### createGroup

    public int createGroup(boolean distributed,
                           java.lang.String communityName,
                           java.lang.String groupName,
                           java.lang.String description,
                           GroupIdentifier theIdentifier)

  Creates a new Group. If operation succeed, the agent will automatically handle two roles: member and group manager.

  Parameters:
    `distributed` - if `true` the new group will be distributed when multiple MadKit kernels are connected.
    `communityName` - the community within the group will be created. If this community does not exist it will be created.
    `groupName` - the name of the new group
    `description` - can be null (thus the description will be the name of the group)
    `theIdentifier` - an object that implements the `GroupIdentifer Interface` which could be used to check if an agent can be admitted in the group. When this object is null, there is no group access control
  Returns:
    - `1` : operation success;
    - `-8` : operation failed ; the group already exists
  Since:
    MadKit 3.0
  See Also:
    `GroupIdentifier`

### createGroup

    public int createGroup(boolean distributed,
                           java.lang.String groupName,
                           java.lang.String description,
                           GroupIdentifier theIdentifier)

  Creates a new Group within the default community public. I.e. it will call createGroup(distributed, Kernel.DEFAULT_COMMUNITY, groupName, description, theIdentifier)

  Parameters:
    `distributed` - if `true` the new group will be distributed when multiple MadKit kernels are connected.
    `groupName` - the name of the new group
    `description` - can be null (thus the description will be the name of the group)
    `theIdentifier` - an object that implements the `GroupIdentifer Interface` which could be used to check if an agent can be admitted in the group. When this object is null, there is no group access control
  Returns:
    - `1` : operation success;
    - `-8` : operation failed ; the group already exists
  Since:
    MadKit 3.0
  See Also:
    `GroupIdentifier`

### requestRole

    public int requestRole(java.lang.String communityName,
                           java.lang.String groupName,
                           java.lang.String roleName,
                           java.lang.Object memberCard)

  Requests a role within a group of a particular community.

  Parameters:
    `communityName` - the group's community.
    `groupName` - the desired group.
    `roleName` - the desired role.
    `memberCard` - the passKey to enter a group. If needed, it is generally delivered by the group's group manager to nice agents :) It can be `null` when the desired group has no security (i.e. was created using `null` for theIdentifier parameter).
  Returns:
    - `1` : operation success;
    - `-1` : the community does not exist.
    - `-2` : the group does not exist;
    - `-4` : the role is already handled by this agent;
    - `-5` : access denied by the manager of that group;
  Since:
    MadKit 3.0
  See Also:
    `GroupIdentifier`

### requestRole

    public int requestRole(java.lang.String groupName,
                           java.lang.String roleName,
                           java.lang.Object memberCard)

  Requests a role within a group of the default community.

  Parameters:
    `groupName` - the group name
    `roleName` - the role name
    `memberCard` - the passKey to enter a group. If needed, it is generally delivered by the group's group manager to nice agents :) It can be `null` when the desired group has no security (i.e. was created using `null` for theIdentifier parameter).
  Returns:
    - `1` : operation success;
    - `-2` : the group does not exist;
    - `-4` : the role is already handled by this agent;
    - `-5` : access denied by the manager of that group;
  Since:
    MadKit 3.0
  See Also:
    `GroupIdentifier`

### leaveRole

    public int leaveRole(java.lang.String communityName,
                         java.lang.String groupName,
                         java.lang.String roleName)

  Abandons an handled role within a group of a particular community.

  Parameters:
    `communityName` - the community name
    `groupName` - the group name
    `roleName` - the role name
  Returns:
    - `1` : operation success;
    - `-1` : the community does not exist.
    - `-2` : the group does not exist;
    - `-6` : the role is not handled;
  Since:
    MadKit 3.0

### leaveRole

    public int leaveRole(java.lang.String groupName,
                         java.lang.String roleName)

  Abandons an handled role within a group of the default community.

  Parameters:
    `groupName` - the group name
    `roleName` - the role name
  Returns:
    - `1` : operation success;
    - `-2` : the group does not exist;
    - `-6` : the role is not handled;
  Since:
    MadKit 3.0

### leaveGroup

    public int leaveGroup(java.lang.String communityName,
                          java.lang.String groupName)

  Makes the agent leave a group of a particular community.

  Parameters:
    `communityName` - the community name
    `groupName` - the group name
  Returns:
    - `1` : operation success;
    - `-1` : the community does not exist;
    - `-2` : the group does not exist;
    - `-7` : the agent is not a member of that group
  Since:
    MadKit 3.0

### leaveGroup

    public int leaveGroup(java.lang.String groupName)

  Makes the agent leave a group of the default community.

  Parameters:
    `groupName` - the group name
  Returns:
    - `1` : operation success;
    - `-2` : the group does not exist;
    - `-7` : the agent is not a member of that group

### joinGroup

    public void joinGroup(java.lang.String groupName)

  Deprecated. As of MadKit 3.0. replaced by `createGroup(boolean,String,String,String,GroupIdentifier)`.

  This call is now equivalent to `createGroup(true, groupName, null, null)` if the group does not exist or `requestRole(groupName, "member", null)` otherwise.

### requestRole

    public void requestRole(java.lang.String groupName,
                            java.lang.String roleName)
                     throws madkit.kernel.RequestRoleException

  Deprecated. As of MadKit 3.0. replaced by `requestRole(String,String,Object)`.

  This call is now equivalent to `requestRole(groupName, roleName, null)`.

  Throws:
    `RequestRoleException`

### foundGroup

    public void foundGroup(java.lang.String groupName)
                    throws madkit.kernel.OrganizationRequestException

  Deprecated. As of MadKit 3.0. replaced by `createGroup(boolean,String,String,String,GroupIdentifier)`.

  This call is now equivalent to `createGroup(true, groupName, null, null)`.

  Throws:
    `OrganizationRequestException`

### getAgentsWithRole

    public AgentAddress[] getAgentsWithRole(java.lang.String communityName,
                                            java.lang.String groupName,
                                            java.lang.String roleName)

  Gets the addresses of all the agents (including this agent if present) that handle this role within this group in this community.

  Parameters:
    `communityName` - the community name
    `groupName` - the group name
    `roleName` - the role name
  Returns:
    the agents which handles this role (including this agent if present). An array of size 0 if no agent match

### getAgentsWithRole

    public AgentAddress[] getAgentsWithRole(java.lang.String groupName,
                                            java.lang.String roleName)

  Gets the addresses of all the agents (including this agent if present) that handle this role within this group.

  Parameters:
    `groupName` - the group name
    `roleName` - the role name
  Returns:
    the agents playing this role, or a 0 size array if there is no agent playing this role

### getAgentWithRole

    public AgentAddress getAgentWithRole(java.lang.String communityName,
                                         java.lang.String groupName,
                                         java.lang.String roleName)

  Gets an agent that handles a given role within a group of a particular community. The agent is chosen randomly among the other agents

  Parameters:
    `groupName` - group name
    `roleName` - role name
    `communityName` - community name
  Returns:
    an agent address if available, `null` otherwise.
  Since:
    MadKit 3.0

### getAgentWithRole

    public AgentAddress getAgentWithRole(java.lang.String groupName,
                                         java.lang.String roleName)

  Gets an agent that handles a given role within a group of the default MadKit community. The agent is chosen randomly among the other agents

  Parameters:
    `groupName` - the group name
    `roleName` - the role name
  Returns:
    an agent address if available, `null` otherwise.

### getMyGroups

    public java.lang.String[] getMyGroups(java.lang.String communityName)

  Gets the name of the groups the agent joined in this community.

  Parameters:
    `communityName` - a string holding a community name
  Returns:
    an array containing the names of the groups the agent is in. It could be 0 size if there is no group
  Since:
    MadKit 3.0

### getMyGroups

    public java.lang.String[] getMyGroups()

  Gets the name of the groups the agent joined in the default community.

  Returns:
    an array containing the names of the groups the agent is in. It could be 0 size if there is no group
  Since:
    MadKit 3.0

### getExistingGroups

    public java.lang.String[] getExistingGroups(java.lang.String communityName)

  returns the names of the groups that exist in this community.

  Parameters:
    `communityName` - the community name
  Returns:
    an array containing the names of the groups which exist in this community. It could be 0 size if there is no group, i.e. the community does not exist.

### getExistingGroups

    public java.lang.String[] getExistingGroups()

  returns an array containing the names of the groups which exist in the default community.

  Returns:
    the existing groups

### isMemberOf

    public boolean isMemberOf(java.lang.String communityName,
                              java.lang.String groupName)

  Tells if the agent is a member of a specific group in a given community

  Returns:
    true if the agent is a member of that group

### isMemberOf

    public boolean isMemberOf(java.lang.String groupName)

  Tells if the agent is a member of a specific group in the default community.

  Parameters:
    `groupName` - the group name
  Returns:
    true if the agent is a member of the group

### isBelongingToGroup

    public boolean isBelongingToGroup(AgentAddress address,
                                      java.lang.String communityName,
                                      java.lang.String groupName)

  Tells if an agent is a member of a specific group in a given community.

  Parameters:
    `address` - the agent address
    `communityName` - the community name
    `groupName` - the group name
  Returns:
    true if the agent is member of a group

### isBelongingToGroup

    public boolean isBelongingToGroup(AgentAddress address,
                                      java.lang.String groupName)

  Tell if an agent is a member of a specific group in the default community

  Returns:
    true if the agent is member of a group

### getMyRoles

    public java.lang.String[] getMyRoles(java.lang.String communityName,
                                         java.lang.String groupName)

  Gets roles currently handled within a group of this community.

  Parameters:
    `communityName` - the community name
    `groupName` - the group name
  Returns:
    the my roles

### getMyRoles

    public java.lang.String[] getMyRoles(java.lang.String groupName)

  Gets roles currently handled within a group of the default community.

  Parameters:
    `groupName` - the group name
  Returns:
    the my roles

### getExistingRoles

    public java.lang.String[] getExistingRoles(java.lang.String communityName,
                                               java.lang.String groupName)

  returns the names of the roles that exist in this (community,group) couple.

  Parameters:
    `communityName` - the community name
    `groupName` - the group name
  Returns:
    the existing roles

### getExistingRoles

    public java.lang.String[] getExistingRoles(java.lang.String groupName)

  returns the names of the roles that exist within this group in the default community.

  Parameters:
    `groupName` - the group name
  Returns:
    the existing roles

### getRoles

    public java.lang.String[] getRoles(java.lang.String groupName)

  Deprecated. As of MadKit 3.0. replaced by `getExistingRoles(String,String)`

### isRole

    public boolean isRole(java.lang.String communityName,
                          java.lang.String groupName,
                          java.lang.String roleName)

  Returns:
    `true` if the role exists (i.e. there is at least one agent having this role); `false` otherwise.

### isRole

    public boolean isRole(java.lang.String groupName,
                          java.lang.String roleName)

  Returns:
    `true` if the role exists (i.e. there is at least one agent with this role); `false` otherwise.

### getGroups

    public java.util.Vector<java.lang.String> getGroups()

  Deprecated. As of MadKit 3.0. replaced by `getExistingGroups(String)`

### isGroup

    public boolean isGroup(java.lang.String communityName,
                           java.lang.String groupName)

  Determines if this group already exists in this community

### isGroup

    public boolean isGroup(java.lang.String groupName)

  Determines if this group already exists in the default community

### isCommunity

    public boolean isCommunity(java.lang.String communityName)

  Determines if this group already exists in this community

  Since:
    MadKit 3.0

### getAvailableCommunities

    public java.lang.String[] getAvailableCommunities()

  returns the available communities

  Since:
    MadKit 3.0

### connectedWithCommunity

    public boolean connectedWithCommunity(java.lang.String communityName)

  returns true if the community is shared on the network

  Since:
    MadKit 3.0

### destroyGroup

    public void destroyGroup(java.lang.String communityName,
                             java.lang.String groupName)

  This method is still experimental. Use with caution ;)

### isMessageBoxEmpty

    public boolean isMessageBoxEmpty()

  Is there any message left to be read ?

### getMessageBoxSize

    public int getMessageBoxSize()

  Gets the number of messages in the message box

### nextMessage

    public Message nextMessage()

  Gets the first message in the queue.

  Returns:
    the first item in the message queue, or null if there is no message available

### receiveMessage

    protected void receiveMessage(Message m)

  This method is invoked by the kernel when the agent receives a message.

  Parameters:
    `m` - the message

### sendMessage

    public void sendMessage(AgentAddress a,
                            Message m)
                     throws MessageException

  Send a message to another agent.

  Parameters:
    `a` - AgentAddress of the receiver
    `m` - Message to be sent
  Throws:
    `MessageException` - if no recipient is found or the message is null

### sendMessage

    public boolean sendMessage(java.lang.String communityName,
                               java.lang.String groupName,
                               java.lang.String roleName,
                               Message m)
                        throws MessageException

  Send a message to an agent having a specific role in a group of this particular community. The corresponding AgentAddress is selected with a getAgentWithRole(..) method call.

  Parameters:
    `communityName` - community in which the group is defined
    `groupName` - group in which the role is defined
    `roleName` - Role of the receiver
    `m` - Message to be sent
  Returns:
    `true`, if an agent has been found as receiver. Beware that this does not mean that the message will be successfully delivered.
  Throws:
    `MessageException` - if the message is null
  Since:
    madkit 3.0
  See Also:
    `getAgentWithRole(String, String, String)`

### sendMessage

    public void sendMessage(java.lang.String groupName,
                            java.lang.String roleName,
                            Message m)
                     throws MessageException

  Send a message to an agent having a specific role in a group of the default community

  Parameters:
    `groupName` - the group name
    `roleName` - the role name
    `m` - the message
  Throws:
    `MessageException` - the message exception
  See Also:
    `sendMessage(String, String, String, Message)`

### broadcastMessage

    public void broadcastMessage(java.lang.String communityName,
                                 java.lang.String groupName,
                                 java.lang.String roleName,
                                 Message m)
                          throws MessageException

  Broadcast a message to every agent having a role in a group. You must assume that the message might not be cloned when sent to local agents

  Parameters:
    `communityName` - the community name
    `groupName` - the group name
    `roleName` - the role name
    `m` - the m
  Throws:
    `MessageException` - the message exception

### broadcastMessage

    public void broadcastMessage(java.lang.String groupName,
                                 java.lang.String roleName,
                                 Message m)
                          throws MessageException

  Throws:
    `MessageException`

### launchAgent

    public void launchAgent(AbstractAgent agent,
                            java.lang.String name,
                            boolean gui)

  This method is called in order to launch an agent from another agent.

  Parameters:
    `agent` - The new agent (already instantiated using a new instruction) .
    `name` - The "usual" name
    `gui` - Should we setup the agent GUI if possible ?

### launchAgent

    public void launchAgent(AbstractAgent agent,
                            java.lang.String name,
                            java.awt.Point position,
                            java.awt.Dimension dim)

  This method try to launch an agent with a GUI with the specified coordinates and dimension.

  Parameters:
    `agent` - the agent
    `name` - the name of the agent
    `position` - the position on the screen
    `dim` - the dimension of the GUI

### restoreAgent

    public void restoreAgent(AbstractAgent agent)

  experimental

### killAgent

    public void killAgent(AbstractAgent agent)

  Kills another agent (or self). This is only possible if the caller launched the target agent itself and still owns a reference to the potential victim

  Parameters:
    `agent` - the agent to kill

### getAddress

    public AgentAddress getAddress()

  Gets the agent's own agent address.

  Returns:
    the address

### setName

    public void setName(java.lang.String theName)

  Change the current agent patronymic name. This name does not need to be unique, and is provided only as a facility

  Parameters:
    `theName` - the new name to set

### getName

    public java.lang.String getName()

  Gets the current agent patronymic name.

  Returns:
    the name of the agent

### getCurrentKernelAddress

    public KernelAddress getCurrentKernelAddress()

  Returns the kernelAddress of the agency where this agent is situated... Generally this value is equal to getAddress().getKernel() but when an agent migrate, this value may change. This method is used to get the real value of the current kernel address.

  Returns:
    the current kernelAddress

### hasGUI

    public boolean hasGUI()

  Check if a bean is running in GUI mode. Usually verified by the Kernel or the host application to setup or not a default graphical interface

  Returns:
    true if a GUI has been instantiated

### initGUI

    public void initGUI()

  This method is called by the specific external graphic system (as the G-Box) to ask the agent to prepare a graphical interface. The agent developer should use a setGUIObject(...) within this method, as well as other necessary initializations. If the developer does not overload this method, a vanilla text output might be used as the default interface.

### setBean

    public void setBean(java.lang.Object theBean)

  Deprecated. As of MadKit 2.0. replaced by `setGUIObject(Object)`

### getBean

    public java.lang.Object getBean()

  Deprecated. As of MadKit 2.0. replaced by `getGUIObject()`

### setGUIObject

    public void setGUIObject(java.lang.Object theBean)

  This method set the bean that will be used to represent the agent in a graphical environment, the agent is also registered as running in GUI mode

  Parameters:
    `theBean` - an allocated graphic component
  Since:
    MadKit 2.0

### getGUIObject

    public java.lang.Object getGUIObject()

  Gets the graphic component representing the agent. Usually called by the host application

  Returns:
    the GUI object
  Since:
    MadKit 2.0

### debug

    public void debug(java.lang.String message)

  Print out debug information only if the debug flag is on.

  Parameters:
    `message` - the message

### setDebug

    public void setDebug(boolean b)

  Sets the debug flag.

  Parameters:
    `b` - the b

### getDebug

    public boolean getDebug()

  Returns:
    true if debug is on

### println

    public void println(java.lang.String message)

  Prints text information in an environment-independent way (GUI, console, ...)

  Parameters:
    `message` - the string

### print

    public void print(java.lang.String message)

  Prints text information in a environment-independent way (GUI, console, ...)

  Parameters:
    `message` - the string

### setOutput

    public void setOutput(java.io.Writer o)

  Deprecated. As of MadKit 2.0. replaced by `setOutputWriter(Writer)`

### setOutputWriter

    public void setOutputWriter(java.io.Writer o)

  Reassigns the "standard" agent text output stream (used by method println).

### disposeMyGUI

    public void disposeMyGUI()

  hide the graphical component that represents the Agent in some higher interface

  Since:
    MadKit 3.0

### hideMyGUI

    public void hideMyGUI()

### redisplayMyGUI

    public void redisplayMyGUI()

  try to restore the graphical component that represents the Agent in some higher interface

  Since:
    MadKit 3.0

### windowClosing

    public void windowClosing(java.awt.AWTEvent we)

### hashCode

    public final int hashCode()

  Overrides:
    `hashCode` in class `java.lang.Object`

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © Madkit Team (O. Gutknecht, J. Ferber, F. Michel et al.) All Rights Reserved.