cz.cuni.amis.pathfinding.map
Interface IPFMap<NODE>

Package class diagram package IPFMap
All Known Subinterfaces:
IPFKnownMap<NODE>

public interface IPFMap<NODE>

This class represents the discrete search space for path-finding algorithms for games. It conceptualize the map/location/environment of the game for the purpose of planners as finite graph whose nodes are easily distinguishable from each others (it is suitable for NavigationGraphs using discrete navigation points, but it is not suitable for GOAP planners for strategic games such as Defcon).

The map is perceived as oriented graph that does not have "multi-edges" (it is not a multigraph).

Every environment must at least provide:

  1. function that can compute neighbors of every node (getNeighbors(Object))
  2. function that provides "cost" of the node (i.e., what is the cost of having the node in the path) (getNodeCost(Object))
  3. function that provides "cost" of the arc (arc == directed edge, i.e., what is the cost of traveling through edge between two nodes in the graph) (IPFMap#getArcCost(Object))

Note that the interface is parameterized by "NODE" which might be arbitrary object, that is you may use POJOs here. But be careful as algorithms using the map usually assumes that Object.hashCode() and Object.equals(Object) are correctly implemented for them (i.e., they may use the nodes as keys inside HashMaps).

Note that the implementation of such interface should not provide any "view hacks", i.e., means for suppressing the presence of some nodes/arc of the graph. Such tweaks should be implemented using IPFMapView.

Note that this interface is suitable for "exploratory" algorithms such as A-Star, that is, algorithms which gradually search the space given some "seed" (starting point). If you wish to use "grand-scale" algorithms such as Floyd-Warshall (where you have to know number of all nodes in advance), use IPFKnownMap.


Method Summary
 int getArcCost(NODE nodeFrom, NODE nodeTo)
          Should return the cost of traveling from "nodeFrom" to "nodeTo".
 Collection<NODE> getNeighbors(NODE node)
          This should return a collection of nodes which are connected to this one by some arc (== oriented edge).
 int getNodeCost(NODE node)
          General cost of having this node at your path.
 

Method Detail

getNeighbors

Collection<NODE> getNeighbors(NODE node)
This should return a collection of nodes which are connected to this one by some arc (== oriented edge). I.e., return collection of nodes that are directly accessible from "node".

"node" MUST NOT BE PART OF THE COLLECTION!

Returned collection must not contain multiple references to a single neighbor (multi-graph is forbidden).

Parameters:
node -
Returns:
all neighbors of the node (arc exists between 'node' and every node inside returned collection)

getNodeCost

int getNodeCost(NODE node)
General cost of having this node at your path. This allows you to say how much each node appeals to the agent, it may specify "this is a cool node, try to get it on your path" (negative cost) or "this is neutral node" (zero cost) or "this is a bad node to have on your path" (positive cost).

This might be highly dependent on the agent so the default implementation will probably just return "0".

Parameters:
node -
Returns:
cost of the node

getArcCost

int getArcCost(NODE nodeFrom,
               NODE nodeTo)
Should return the cost of traveling from "nodeFrom" to "nodeTo". You can be sure that "nodeTo" is among the neighbors of "nodeFrom" as they were returned by getNeighbors(Object) or from IPFMapView#getExtraNeighbors(Object).

Note that notion of "cost" might be highly dependent on the agent, thus it may have the sense to provide it only a general distance between "nodeFrom" and "nodeTo".

The method can be also perceived as having name "getDistance".

Parameters:
nodeFrom -
nodeTo -
Returns:
cost of an arc


Copyright © 2013 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.