edu.columbia.cs.coms4701.agent.environments.robot
Class RoombaEnvironment

java.lang.Object
  extended by edu.columbia.cs.coms4701.agent.environments.simple.AbstractEnvironment<K,P,A>
      extended by edu.columbia.cs.coms4701.agent.environments.grid.AbstractGridEnvironment<RobotAction,RobotPercept,RobotAgent>
          extended by edu.columbia.cs.coms4701.agent.environments.robot.RoombaEnvironment
All Implemented Interfaces:
Environment<RobotAction,RobotPercept,RobotAgent>, GridEnvironment<RobotAction,RobotPercept,RobotAgent>

public class RoombaEnvironment
extends AbstractGridEnvironment<RobotAction,RobotPercept,RobotAgent>
implements GridEnvironment<RobotAction,RobotPercept,RobotAgent>

The environment in which a robo-vac agent lives, spends its days, and dies.

Version:
0.1

User: aaron Date: Aug 25, 2006 Time: 9:13:06 AM

Author:
aaron@cs

Field Summary
 
Fields inherited from class edu.columbia.cs.coms4701.agent.environments.grid.AbstractGridEnvironment
map
 
Fields inherited from class edu.columbia.cs.coms4701.agent.environments.simple.AbstractEnvironment
agents, counter, environmentObjects, environmentObservers
 
Constructor Summary
RoombaEnvironment(int timeAllowed, GridMap theMap)
          Constructs a new RoombaEnvironment from the given GridMap.
RoombaEnvironment(int timeAllowed, int height, int width)
          Constructs a new RoombaEnvironment that will be of the given height and width.
 
Method Summary
 void addAgent(RobotAgent theAgent)
          Extended to initialize robot performance measures.
 void agentDrivenChange(RobotAgent theAgent, RobotAction theAction)
          Changes the state of zero or more environment objects, given an agent and the action that the agent selected.
 void dynamicChange()
          Extended to calculate the performance measure in each clock tick.
 java.lang.Integer getMaximumDirtPieces()
           
 void initialSetup()
          Does the initial setup of the Roomba environment.
 boolean isDone()
          Halts the environment after the allotted time has passed, or if a robot has asked to stop, or when a robot has performance = 1.
 java.util.Set<RobotPercept> perceptsForAgent(RobotAgent theAgent)
          Returns a set of percepts for the given agent.
static GridMap readMapFromStream(java.io.InputStream theStream)
          Convenience function which constructs a GridMap by parsing a simple text format.
 void startingToRunSetup()
          Initializes the dirt count.
 
Methods inherited from class edu.columbia.cs.coms4701.agent.environments.grid.AbstractGridEnvironment
addEnvironmentObject, getMap
 
Methods inherited from class edu.columbia.cs.coms4701.agent.environments.simple.AbstractEnvironment
addEnvironmentObserver, executeStep, getAgents, getCounter, getEnvironmentObjects, run
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.columbia.cs.coms4701.agent.environments.grid.GridEnvironment
getMap
 
Methods inherited from interface edu.columbia.cs.coms4701.agent.Environment
addEnvironmentObject, addEnvironmentObserver, executeStep, getAgents, getCounter, getEnvironmentObjects, run
 

Constructor Detail

RoombaEnvironment

public RoombaEnvironment(int timeAllowed,
                         int height,
                         int width)
Constructs a new RoombaEnvironment that will be of the given height and width.

Note that the environment's GridMap is not actually constructed until #initialSetup is invoked. This permits observers to be attached first.

Parameters:
timeAllowed - the number of steps the robot is allowed to run before halting the environment
height -
width -

RoombaEnvironment

public RoombaEnvironment(int timeAllowed,
                         GridMap theMap)
Constructs a new RoombaEnvironment from the given GridMap. Useful for constructing many environments from a single map.

Parameters:
timeAllowed - the number of steps the robot is allowed to run before halting the environment
theMap - a GridMap containing RoombaDirt and GridObstacles
Method Detail

readMapFromStream

public static GridMap readMapFromStream(java.io.InputStream theStream)
Convenience function which constructs a GridMap by parsing a simple text format.

The text of the stream must contain:

The returned map may be used with the #RoombaEnvironment(GridMap) constructor.

Returns:
GridMap parsed from the text stream.
Throws:
java.lang.RuntimeException - if the stream cannot be parsed

isDone

public boolean isDone()
Halts the environment after the allotted time has passed, or if a robot has asked to stop, or when a robot has performance = 1.

Specified by:
isDone in interface Environment<RobotAction,RobotPercept,RobotAgent>
Overrides:
isDone in class AbstractEnvironment<RobotAction,RobotPercept,RobotAgent>

initialSetup

public void initialSetup()
Does the initial setup of the Roomba environment.

Specified by:
initialSetup in interface Environment<RobotAction,RobotPercept,RobotAgent>
Overrides:
initialSetup in class AbstractEnvironment<RobotAction,RobotPercept,RobotAgent>

startingToRunSetup

public void startingToRunSetup()
Initializes the dirt count.

Specified by:
startingToRunSetup in interface Environment<RobotAction,RobotPercept,RobotAgent>
Overrides:
startingToRunSetup in class AbstractEnvironment<RobotAction,RobotPercept,RobotAgent>

dynamicChange

public void dynamicChange()
Extended to calculate the performance measure in each clock tick.

Specified by:
dynamicChange in interface Environment<RobotAction,RobotPercept,RobotAgent>
Overrides:
dynamicChange in class AbstractEnvironment<RobotAction,RobotPercept,RobotAgent>

perceptsForAgent

public java.util.Set<RobotPercept> perceptsForAgent(RobotAgent theAgent)
Returns a set of percepts for the given agent.

In the RoombaEnvironment, an agent's first set of precepts will include:

Subsequent percepts will include only a RobotSuccessPercept, indicating whether the previously chosen action succeeded or not.

Specified by:
perceptsForAgent in interface Environment<RobotAction,RobotPercept,RobotAgent>
Specified by:
perceptsForAgent in class AbstractEnvironment<RobotAction,RobotPercept,RobotAgent>

agentDrivenChange

public void agentDrivenChange(RobotAgent theAgent,
                              RobotAction theAction)
Changes the state of zero or more environment objects, given an agent and the action that the agent selected.

In the RoombaEnvironment, this consists of examining a robot's proposed action, determining whether it will bring the robot beyond the boundaries of the map or into collision with a

Specified by:
agentDrivenChange in interface Environment<RobotAction,RobotPercept,RobotAgent>
Specified by:
agentDrivenChange in class AbstractEnvironment<RobotAction,RobotPercept,RobotAgent>
Parameters:
theAgent - the agent that just selected an action
theAction - the action selected

addAgent

public void addAgent(RobotAgent theAgent)
Extended to initialize robot performance measures.

Specified by:
addAgent in interface Environment<RobotAction,RobotPercept,RobotAgent>
Overrides:
addAgent in class AbstractEnvironment<RobotAction,RobotPercept,RobotAgent>

getMaximumDirtPieces

public java.lang.Integer getMaximumDirtPieces()