ai.worlds
Class Environment

java.lang.Object
  extended byai.worlds.Environment
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
GridEnvironment

public abstract class Environment
extends java.lang.Object
implements java.lang.Runnable

A generic environment. All environments must implement getPercept, performanceMeasure, snapshot, termination, and legalAction methods

Author:
Jill Zimmerman -- jill.zimmerman@goucher.edu

Field Summary
 Agent[] agents
          The agents within the environment.
 boolean display
          Flag to indicate whether to display
 int maxSteps
          The maximum number of steps.
 java.lang.Thread runner
          The animation thread.
 int step
          The current step number.
 
Constructor Summary
Environment()
           
 
Method Summary
 void displayEnv()
          Perform one animation step if the display flag is set.
 void executeAgentActions()
          Each agent executes its current action.
abstract  java.lang.Object getPercept(Agent a)
          Get the current percept.
abstract  boolean legalAction(java.lang.String a)
          Determine if action is legal.
abstract  int performanceMeasure(Agent a)
          Score the performance of the agent.
 void run()
          Run the environment until maximum steps or termination criteria are met.
abstract  void snapshot()
          A snapshot of the environment.
 void start()
           
 void stop()
           
 void takeStep()
          Each agent determines and performs one action.
abstract  boolean termination()
          Determine if all agents have terminated.
 void updateEnv()
          Update the environment after each step.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

agents

public Agent[] agents
The agents within the environment.


step

public int step
The current step number.


maxSteps

public int maxSteps
The maximum number of steps.


display

public boolean display
Flag to indicate whether to display


runner

public java.lang.Thread runner
The animation thread.

Constructor Detail

Environment

public Environment()
Method Detail

getPercept

public abstract java.lang.Object getPercept(Agent a)
Get the current percept.

Parameters:
a - Agent in the environment

performanceMeasure

public abstract int performanceMeasure(Agent a)
Score the performance of the agent.

Parameters:
a - Agent in the environment

snapshot

public abstract void snapshot()
A snapshot of the environment.


termination

public abstract boolean termination()
Determine if all agents have terminated.


legalAction

public abstract boolean legalAction(java.lang.String a)
Determine if action is legal.

Parameters:
a - Possible action.

start

public void start()

stop

public void stop()

run

public void run()
Run the environment until maximum steps or termination criteria are met.

Specified by:
run in interface java.lang.Runnable

takeStep

public void takeStep()
Each agent determines and performs one action.


displayEnv

public void displayEnv()
Perform one animation step if the display flag is set.


updateEnv

public void updateEnv()
Update the environment after each step.


executeAgentActions

public void executeAgentActions()
Each agent executes its current action.