vacworld
Class VacuumWorld

java.lang.Object
  extended byagent.Environment
      extended byvacworld.VacuumWorld

public class VacuumWorld
extends Environment

A simulator for the vacuum cleaning world environment. This environment is inaccessible, deterministic, static and discrete.


Field Summary
protected  boolean interactive
           
protected  int numBumps
           
protected  int numMoves
           
protected  int numSucks
           
protected  int numTurns
           
protected  java.io.PrintStream output
           
protected  int totalScore
           
 
Fields inherited from class agent.Environment
agents, state
 
Constructor Summary
VacuumWorld()
           
VacuumWorld(java.io.PrintStream output, boolean interactive)
           
 
Method Summary
 void addAgent(Agent agent)
          Add a new agent to the environment.
protected  int getNumActions()
          Returns the number of actions the agent has executed.
protected  int getNumDirtyLocs()
           
protected  Percept getPercept(Agent a)
          Create a percept for an agent.
protected  int getPerformanceMeasure()
          Returns the performance measure of the agent in the current environment.
 boolean gotHome()
          Returns true if the robot has turned itself off in its origin square.
protected  boolean isComplete()
          The simulation is complete when the robot has performed its ShutOff action.
static void main(java.lang.String[] args)
          Runs the program.
protected  void printScore(java.io.PrintStream out)
           
 void start(State initState)
          Starts the simulation.
protected  void updateState(Agent a, Action action)
          Execute an agent's action and update the environment's state.
protected  void waitForUser()
          Pause simulation until user has pressed a key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numMoves

protected int numMoves

numTurns

protected int numTurns

numSucks

protected int numSucks

numBumps

protected int numBumps

totalScore

protected int totalScore

output

protected java.io.PrintStream output

interactive

protected boolean interactive
Constructor Detail

VacuumWorld

public VacuumWorld()

VacuumWorld

public VacuumWorld(java.io.PrintStream output,
                   boolean interactive)
Method Detail

addAgent

public void addAgent(Agent agent)
Add a new agent to the environment. Since the vacuum cleaning world is a single agent environment, this method should only be called once per object.

Specified by:
addAgent in class Environment

isComplete

protected boolean isComplete()
The simulation is complete when the robot has performed its ShutOff action.

Specified by:
isComplete in class Environment

getPercept

protected Percept getPercept(Agent a)
Create a percept for an agent. This implements the see: E -> Per function.

Specified by:
getPercept in class Environment

updateState

protected void updateState(Agent a,
                           Action action)
Execute an agent's action and update the environment's state.

Overrides:
updateState in class Environment

start

public void start(State initState)
Starts the simulation. We override the method in agent.Environment so that VacuumWorld states can be displayed to a selected output stream.

Overrides:
start in class Environment

waitForUser

protected void waitForUser()
Pause simulation until user has pressed a key.


main

public static void main(java.lang.String[] args)
Runs the program.


getNumDirtyLocs

protected int getNumDirtyLocs()

gotHome

public boolean gotHome()
Returns true if the robot has turned itself off in its origin square.


getNumActions

protected int getNumActions()
Returns the number of actions the agent has executed.


getPerformanceMeasure

protected int getPerformanceMeasure()
Returns the performance measure of the agent in the current environment.

Specified by:
getPerformanceMeasure in class Environment

printScore

protected void printScore(java.io.PrintStream out)