|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object aima.search.map.ExtendableMap
public class ExtendableMap
Implements a map with locations, distance labeled links between the locations, straight line distances, and 2d-placement positions of locations. Locations are represented by strings and travel distances by integer values. Locations and links can be added dynamically and removed after creation. This enables to read maps from file or to modify them with respect to newly obtained knowledge.
Constructor Summary | |
---|---|
ExtendableMap()
Creates an empty map. |
Method Summary | |
---|---|
void |
addBidirectionalLink(java.lang.String fromLocation,
java.lang.String toLocation,
java.lang.Double distance)
Adds a connection which can be traveled in both direction. |
void |
addUnidirectionalLink(java.lang.String fromLocation,
java.lang.String toLocation,
java.lang.Double distance)
Adds a one-way connection to the map. |
void |
clear()
Removes everything. |
void |
clearLinks()
Clears all connections but keeps location position informations. |
java.lang.Double |
getDistance(java.lang.String fromLocation,
java.lang.String toLocation)
Returns the travel distance between the two specified locations if they are linked by a connection and null otherwise. |
java.util.List<java.lang.String> |
getLocations()
Returns a list of all locations. |
java.util.List<java.lang.String> |
getLocationsLinkedTo(java.lang.String fromLocation)
Answers to the question: Where can I get, following one of the connections starting at the specified location? |
Point2D |
getPosition(java.lang.String loc)
Returns an array with two integers describing the the position of the specified location. |
boolean |
isLocation(java.lang.String str)
Checks whether the given string is the name of a location. |
java.lang.String |
randomlyGenerateDestination()
Returns a location which is selected by random. |
void |
removeBidirectionalLink(java.lang.String fromLocation,
java.lang.String toLocation)
Removes the two corresponding one-way connections. |
void |
removeUnidirectionalLink(java.lang.String fromLocation,
java.lang.String toLocation)
Removes a one-way connection. |
void |
setDistAndDirToRefLocation(java.lang.String loc,
double dist,
int dir)
Defines the position of a location within the map. |
void |
setPosition(java.lang.String loc,
double x,
double y)
Defines the position of a location as with respect to an orthogonal coordinate system. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ExtendableMap()
Method Detail |
---|
public void clear()
public void clearLinks()
public java.util.List<java.lang.String> getLocations()
getLocations
in interface Map
public boolean isLocation(java.lang.String str)
public java.util.List<java.lang.String> getLocationsLinkedTo(java.lang.String fromLocation)
getLocationsLinkedTo
in interface Map
public java.lang.Double getDistance(java.lang.String fromLocation, java.lang.String toLocation)
getDistance
in interface Map
public void addUnidirectionalLink(java.lang.String fromLocation, java.lang.String toLocation, java.lang.Double distance)
public void addBidirectionalLink(java.lang.String fromLocation, java.lang.String toLocation, java.lang.Double distance)
public java.lang.String randomlyGenerateDestination()
randomlyGenerateDestination
in interface Map
public void removeUnidirectionalLink(java.lang.String fromLocation, java.lang.String toLocation)
public void removeBidirectionalLink(java.lang.String fromLocation, java.lang.String toLocation)
public void setPosition(java.lang.String loc, double x, double y)
public void setDistAndDirToRefLocation(java.lang.String loc, double dist, int dir)
dist=0
and dir=0
) and all the other location should be placed
relative to it.
loc
- location namedist
- distance to a reference positiondir
- bearing (compass direction) in which the location is seen from
the reference positionpublic Point2D getPosition(java.lang.String loc)
getPosition
in interface Map
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |