agent
Class Environment

java.lang.Object
  extended byagent.Environment
Direct Known Subclasses:
VacuumWorld

public abstract class Environment
extends java.lang.Object

The top-level class for an agent simulation. This can be used for either single or multi-agent environments. This is intended for simulating static environments in which the agents take turns acting. An environment in which the agent could decide when to sense and act, or a dynamic multi-agent environment would require multiple threads, one for managing the way the environment changes and one for each agent.


Field Summary
protected  java.util.Vector agents
          The set of agents in the environment.
protected  State state
          The current state of the environment.
 
Constructor Summary
Environment()
          Construct a new environment.
 
Method Summary
abstract  void addAgent(Agent agent)
          Add a new agent to the environment.
protected abstract  Percept getPercept(Agent a)
          Create a percept for an agent.
protected abstract  int getPerformanceMeasure()
          Return the performance measure of the agent in the current environment.
protected abstract  boolean isComplete()
          Is the simulation over? Returns true if it is, otherwise false.
 void start(State initState)
          Run the simulation starting from a given state.
protected  void updateState(Agent a, Action action)
          Execute an agent's action and update the environment's state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

agents

protected java.util.Vector agents
The set of agents in the environment.


state

protected State state
The current state of the environment.

Constructor Detail

Environment

public Environment()
Construct a new environment. Initialize the agents vector.

Method Detail

addAgent

public abstract void addAgent(Agent agent)
Add a new agent to the environment.


start

public void start(State initState)
Run the simulation starting from a given state. This consists of a sense-act loop for each agent.


isComplete

protected abstract boolean isComplete()
Is the simulation over? Returns true if it is, otherwise false.


getPercept

protected abstract Percept getPercept(Agent a)
Create a percept for an agent. This effectively implements the see: E -> Per function. Implementations of this method should call the Percept(State,Agent) constructor of the appropriate Percept subclass in order to create an appropriate percept based on the current state.

DESIGN NOTE: The see() function is not implemented in the agent because the agent shouldn't have direct access to the environment. Otherwise, the agent could "cheat" in inaccessible environments and "see" things that wasn't part of its percept.


updateState

protected void updateState(Agent a,
                           Action action)
Execute an agent's action and update the environment's state. This effectively applies the state transformer function T:R^Ac -> P(E) to select a subsequent state. Note, if an action is nondeterministic, one of the resulting states is chosen.


getPerformanceMeasure

protected abstract int getPerformanceMeasure()
Return the performance measure of the agent in the current environment. Higher values are considered better.