|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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:
getNeighbors(Object)
)getNodeCost(Object)
)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 HashMap
s).
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 |
---|
Collection<NODE> getNeighbors(NODE node)
"node" MUST NOT BE PART OF THE COLLECTION!
Returned collection must not contain multiple references to a single neighbor (multi-graph is forbidden).
node
-
int getNodeCost(NODE node)
This might be highly dependent on the agent so the default implementation will probably just return "0".
node
-
int getArcCost(NODE nodeFrom, NODE nodeTo)
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".
nodeFrom
- nodeTo
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |