aima.gui.applications.search.map
Class MapAgentModel

java.lang.Object
  extended by aima.basic.BasicEnvironmentView
      extended by aima.gui.framework.AgentAppModel
          extended by aima.gui.applications.search.map.MapAgentModel

public class MapAgentModel
extends AgentAppModel

Provides a ready-to-use implementation of a model for route planning agent applications. It is based on a scenario description and a list of destinations. Some features are not used. Subclasses can support those features by overriding the methods hasInfos(String), and hasObjects(String).


Nested Class Summary
 
Nested classes/interfaces inherited from class aima.gui.framework.AgentAppModel
AgentAppModel.ModelChangedListener
 
Field Summary
protected  java.util.List<java.lang.String> destinations
          A list of location names, possibly null.
protected  Scenario scenario
          A scenario.
 
Fields inherited from class aima.gui.framework.AgentAppModel
listeners
 
Constructor Summary
MapAgentModel()
           
 
Method Summary
 void clearTourHistory()
          Clears the list of already visited locations.
 void envChanged(java.lang.String command)
          Reacts on environment changes and updates the tour history.
 Agent getAgent()
          Returns the agent.
 Map getAgentMap()
          Returns the map used by the agent.
 Map getEnvMap()
          Returns the map used by the environment.
 java.util.List<java.lang.String> getLocations()
          Returns all location names mentioned in the environment map or in the agent map.
 Point2D getLocCoords(java.lang.String loc)
          Returns the coordinates of the specified location.
 java.util.List<java.lang.String> getTourHistory()
          Returns a list of all already visited agent locations.
 boolean hasInfos(java.lang.String loc)
          Checks whether special informations can be perceived at the location.
 boolean hasObjects(java.lang.String loc)
          Checks whether interesting objects can be perceived at the location.
 boolean isDestination(java.lang.String loc)
          Checks whether a given location is one of the specified destinations.
 boolean isEmpty()
          Checks whether there is a scenario available.
 boolean isStart(java.lang.String loc)
          Checks whether a given location is the initial location of the agent.
 void prepare(Scenario s, java.util.List<java.lang.String> d)
          Assigns values to the attributes scenario and destinations, clears the history and informs all interested listeners about the model change.
 
Methods inherited from class aima.gui.framework.AgentAppModel
addModelChangedListener, fireModelChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

scenario

protected Scenario scenario
A scenario.


destinations

protected java.util.List<java.lang.String> destinations
A list of location names, possibly null.

Constructor Detail

MapAgentModel

public MapAgentModel()
Method Detail

getTourHistory

public java.util.List<java.lang.String> getTourHistory()
Returns a list of all already visited agent locations.


clearTourHistory

public void clearTourHistory()
Clears the list of already visited locations.


envChanged

public void envChanged(java.lang.String command)
Reacts on environment changes and updates the tour history. The command string is always send to all registered model change listeners. If the command is a location name (with attached position info) or Agent.NO_OP, the agent's current location is added to the tour history and all listeners are informed about the change.

Overrides:
envChanged in class AgentAppModel

prepare

public void prepare(Scenario s,
                    java.util.List<java.lang.String> d)
Assigns values to the attributes scenario and destinations, clears the history and informs all interested listeners about the model change.

Parameters:
s - A scenario or null.
d - List of location names or null.

isEmpty

public boolean isEmpty()
Checks whether there is a scenario available.


getLocations

public java.util.List<java.lang.String> getLocations()
Returns all location names mentioned in the environment map or in the agent map.


getAgentMap

public Map getAgentMap()
Returns the map used by the agent.


getEnvMap

public Map getEnvMap()
Returns the map used by the environment.


getAgent

public Agent getAgent()
Returns the agent.


isStart

public boolean isStart(java.lang.String loc)
Checks whether a given location is the initial location of the agent.


isDestination

public boolean isDestination(java.lang.String loc)
Checks whether a given location is one of the specified destinations.


getLocCoords

public Point2D getLocCoords(java.lang.String loc)
Returns the coordinates of the specified location.


hasInfos

public boolean hasInfos(java.lang.String loc)
Checks whether special informations can be perceived at the location. This implementation always returns false.


hasObjects

public boolean hasObjects(java.lang.String loc)
Checks whether interesting objects can be perceived at the location. This implementation always returns false.