-
Notifications
You must be signed in to change notification settings - Fork 6
Architecture: Environment
In an agent society simulation the environment represents a shared state between all the agents. It can have attributes of it's own, such as obstacles, or attributes of individual agents, such as their locations. In the simulation we want agents to be able to access this shared state. This process is sometimes known as perception. However this perception may be limited by the environment (e.g. line of sight, limited distance of sight), so for the purpose of simulating these limitation we would like a further layer between the shared state and Participants which provide a 'service' to the environment.
Additionally the shared state of the environment can change. Agents perform actions which can influence and cause changes in the environment, such as movement. The environment must be able to interpret these actions, decide whether they are possible or not, then perhaps inform the agent of the result of this action.
Now we have defined the requirements of the environment within the Presage simulation we will explain their implementation.
In order to ensure the environment is always aware of agents who are acting within it, and to ensure that agent actions cannot be spoofed we require that agents register and deregister with the environment when they enter and leave respectively. The EnvironmentConnector interface provides the methods to do this, as well as acting once we are registered.
The register function in EnvironmentConnector requires an EnvironmentRegistrationRequest. This requires the participant's ID, the Participant object itself, and optionally a set of ParticipantSharedState. A ParticipantSharedState is a generic holder for variables which represent elements of the participant's state which the environment should know about (e.g. location), and therefore should be perceivable by other agents.
The registration will return an EnvironmentRegistrationResponse. This contains an authkey. This is a shared secret between the environment and participant which will be used to authenticate further interactions between agent and environment and should be saved by the participant. Secondly it has a set of EnvironmentServices. These are the intermediary layer between the shared state and agent, and can be used to perform 'perceptions' in the environment.
You can act on the environment by calling EnvironmentConnector.act() with an Action, your actor ID and authkey (received during registration). The environment must have an associated ActionHandler which can handle the Action or it will throw an ActionHandlingException, otherwise the action will be processed by the environment.
In the case an incorrect authkey is provided an InvalidAuthkeyException will be thrown.