public class FloydWarshallMap extends SensorModule<UDKBot>
It should be initialized upon receiving MapPointListObtained event.
It precomputes all the paths inside the environment using Floyd-Warshall
algorithm (O(n^3)). Use getReachable(), getDistance(), getPath() to obtain
the info about the path.
Based upon the implementation from Martin Krulis with his kind consent - Thank you!
NOTE: requires O(navpoints.size^3) of memory ~ which is 10000^3 at max for UT2004 (usually maps have 3000 navpoints max). If you are going to use more than one bot in your simulation, we advise you to create a singleton that will provide an instance for all your bots.
| Modifier and Type | Class and Description |
|---|---|
static class |
FloydWarshallMap.PathMatrixNode |
| Modifier and Type | Field and Description |
|---|---|
static int |
BAD_EDGE_FLAG
Flag mask representing unusable edge.
|
protected int |
badEdgeFlag
Prohibited edges.
|
protected Map<Integer,NavPoint> |
indicesNavPoints
Mapping indices to nav points.
|
protected Map<UnrealId,Integer> |
navPointIndices
Hash table converting navPoint IDs to our own indices.
|
protected FloydWarshallMap.PathMatrixNode[][] |
pathMatrix |
worldViewagent, controller, eventBus, log| Constructor and Description |
|---|
FloydWarshallMap(UDKBot bot) |
FloydWarshallMap(UDKBot bot,
int badEdgeFlag,
Logger log) |
FloydWarshallMap(UDKBot bot,
Logger log) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
checkLink(NavPointNeighbourLink edge)
Checks whether the edge is usable.
|
float |
getDistance(NavPoint from,
NavPoint to)
Calculate's distance between two nav points (using pathfinding).
|
List<NavPoint> |
getPath(NavPoint from,
NavPoint to)
Returns path between navpoints 'from' -> 'to'.
|
protected FloydWarshallMap.PathMatrixNode |
getPathMatrixNode(NavPoint np1,
NavPoint np2) |
protected void |
performFloydWarshall(List<NavPoint> navPoints) |
protected void |
performFloydWarshall(MapPointListObtained map) |
boolean |
reachable(NavPoint from,
NavPoint to)
Whether navpoint 'to' is reachable from the navpoint 'from'.
|
String |
toString() |
cleanUp, getComponentId, getLog, getState, initComponentId, isRunning, kill, pause, reset, resume, start, stoppublic static final int BAD_EDGE_FLAG
protected int badEdgeFlag
protected Map<UnrealId,Integer> navPointIndices
protected Map<Integer,NavPoint> indicesNavPoints
WILL BE NULL AFTER CONSTRUCTION! SERVES AS A TEMPORARY "GLOBAL VARIABLE" DURING FLOYD-WARSHALL COMPUTATION AND PATH RECONSTRUCTION.
protected FloydWarshallMap.PathMatrixNode[][] pathMatrix
public FloydWarshallMap(UDKBot bot)
protected void performFloydWarshall(MapPointListObtained map)
public boolean checkLink(NavPointNeighbourLink edge)
from - Starting nav point.edge - NeighNav object representing the edge.protected FloydWarshallMap.PathMatrixNode getPathMatrixNode(NavPoint np1, NavPoint np2)
public boolean reachable(NavPoint from, NavPoint to)
from - to - public float getDistance(NavPoint from, NavPoint to)
public List<NavPoint> getPath(NavPoint from, NavPoint to)
from - to - public String toString()
toString in class AgentModule<UDKBot>Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.