edu.columbia.cs.coms4701.agent.environments.grid
Interface GridMap

All Superinterfaces:
EnvironmentObject
All Known Implementing Classes:
SimpleGridMap

public interface GridMap
extends EnvironmentObject

Represents an environment object that can be used to keep track of the location of other objects in a 2-dimensional grid.

Initially, a rectangular location and size are set. Then, environment objects can be set to particular locations (the GridMap should take care of updating the location of GridObjects, so the environment only has to manipulate locations once.)

GridObjects can be queried directly for their location, or the GridMap can be queried to find out what objects are in a particular location.

Version:
0.1

User: aaron Date: Aug 25, 2006 Time: 2:27:08 PM

Author:
aaron@cs

Method Summary
 DiscreteRectangle getRectangle()
          Returns the location and size of the map.
 boolean locationIsWithinBounds(DiscretePoint2D theLocation)
          Returns true if the given location is within the bounds of the map.
 java.util.Set<GridObject> objectsAtLocation(DiscretePoint2D theLocation)
          Returns a set (possibly empty) of the environment objects known to be present at the given location.
 void setRectangle(DiscreteRectangle theRectangle)
          Sets the location and size of the map.
 void updateObjectLocation(GridObject theObject, DiscretePoint2D theLocation)
          Updates the location of a GridObject.
 
Methods inherited from interface edu.columbia.cs.coms4701.agent.EnvironmentObject
addPropertyChangeListener, isAlive, removePropertyChangeListener, setAlive
 

Method Detail

setRectangle

void setRectangle(DiscreteRectangle theRectangle)
Sets the location and size of the map. Subinterfaces might permit fancier shapes than mere rectangles.

Parameters:
theRectangle -

getRectangle

DiscreteRectangle getRectangle()
Returns the location and size of the map.

Returns:
rectangle representing the boundaries of the map.

updateObjectLocation

void updateObjectLocation(GridObject theObject,
                          DiscretePoint2D theLocation)
Updates the location of a GridObject.

The method should update both the object's location property, and whatever internal mechanism is used to permit efficient querying of locations for present objects.

Note that the method should also make sure to remove the old record of the object's location, if it has a current location!

Parameters:
theObject -
theLocation -

objectsAtLocation

java.util.Set<GridObject> objectsAtLocation(DiscretePoint2D theLocation)
Returns a set (possibly empty) of the environment objects known to be present at the given location.

Parameters:
theLocation -
Returns:
zero or more GridObjects known to be at the given location.

locationIsWithinBounds

boolean locationIsWithinBounds(DiscretePoint2D theLocation)
Returns true if the given location is within the bounds of the map.

More complex subclasses may find this useful.

Returns:
true if location is "on" the map, false otherwise