|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcz.cuni.pogamut.Client.PathManager
public class PathManager
This class encapsulate work with paths during navigation
so it is on one place and it is clearer what is going on with them
1) call either retrievePathGB() or retrievePathAStart()
2) check it's result ... if PATH_FOUND then use getPath() to get found path
3) When the path is successfully retrieved, you may then call runAlongPath() method.
Nested Class Summary | |
---|---|
private static class |
PathManager.Lift
|
static class |
PathManager.PathResult
Result when finding the path... |
private static class |
PathManager.RunAlongPathState
|
static class |
PathManager.RunResult
Result of the runAlongPath. |
Field Summary | |
---|---|
private java.util.List<Triple> |
agentLocationHistory
History of agent's location - stuck check is working over this... |
private AgentBody |
body
AgentBody, we need it to be able to issue commands. |
private NeighNav |
edge
Edge between navpoints we're running over. |
private NavPoint |
fromNavPoint
Navpoint we're running from. |
private GameMap |
gameMap
Owner of the PathManager |
private long |
lastAgentLocationAddedMillis
When was the last time we've added the agent location to the history? |
private long |
lastJumpMillis
When was the last time the bot has tried to jump over obstacle, millis |
private long |
lastPathRequestSent
When was the last time System.currentTimeMillis() when we've asked GB to get us a path. |
private int |
liftAttempts
How many times we've tried to get to the lift. |
private java.util.logging.Logger |
log
Platform log. |
private java.lang.String |
logPrefix
Log prefix. |
private Mover |
myMover
Filled when we have to enter the lift. |
private java.util.ArrayList<NavPoint> |
path
Current path the manager is working over |
private static int |
PATH_ID_START_COUNTER
First path id to use. |
static long |
PATH_REQUEST_TIMEOUT
How many millis we will wait for the GB to answer GETPATH command before we timeout... |
private int |
pathId
Last used pathId when communicating with GB. |
private boolean |
pathRequestSent
Whether we sent request to the GB to get the path. |
protected java.util.HashMap<java.lang.String,java.util.ArrayList<NavPoint>> |
pathsFromGB
Structure that stores collected paths according to their id. |
private Triple |
pathToLocation
Last path requested was for this location |
private boolean |
returningToLiftExit
Whether the command to return to lift exit has been issued. |
private PathManager.RunAlongPathState |
runningState
State of the runAlongPath() that allows us to handle lifts. |
private int |
runningToNavPointIndex
Index of the navpoint we're running to. |
private NavPoint |
toNavPoint
Navpoint we're running to. |
private boolean |
waitingForLift
If true the bot has started to wait for the lift... |
private long |
waitingForLiftStartedMillis
Time when the bot started to wait for the lift. |
private double |
zCoordWhenLiftCenterReached
What was the bot z-coord when lift center has been reached? |
Constructor Summary | |
---|---|
PathManager(GameMap gameMap,
AgentBody body,
java.util.logging.Logger platformLog)
Creates a new instance of PathManager, body is passed so the PathManager may hook a listener to sniff PATH messages and SPAWN messages (to know when to restart itself) and issue commands. |
Method Summary | |
---|---|
private double |
deviationFromTheRunningLine(Triple agentLocation)
|
private NavPoint |
getNavPointFromMemory(NavPoint np)
Retrieves navpoint from memory or if not found returns current 'np'. |
private NavPoint |
getNextNavPoint()
|
java.util.ArrayList<NavPoint> |
getPath()
When you get PATH_FOUND result from either retrievePathGB() or retrievePathAStart(), you may call this method to actually get that path. |
java.util.ArrayList<NavPoint> |
getPath(java.lang.String pathId)
Returns path of specific id if present. |
private PathManager.Lift |
isNavpointLift(NavPoint np)
Called if toNavPoint is not null, checks whether we're not entering the lift with the next navpoint. |
private boolean |
isStucked()
|
private void |
jumpCheck(Triple agentLocation)
|
private Mover |
locateMover(Triple location)
|
private double |
maxDistanceInAgentLocationHistory()
Returns max distance between two locations in agentLocationHistory |
void |
receiveMessage(RcvMsgEvent e)
Saves obtained paths from GB and restart path manager if bot is respawned. |
void |
restartPathManager()
Call to reset all variables of the path manager - called also internally when restarting paths. |
void |
restartRunAlongPath()
Used to restart the running along path - all variables cleared - called automaticaly during restartPathManager() or agent respawn. |
PathManager.PathResult |
retrievePathAStar(NavPoint target)
Use this method before you call runAlongPath() to prepare the path to run along :) When PATH_FOUND is returned, you may then call runAlongPath(). |
PathManager.PathResult |
retrievePathGB(Triple location)
Use this method before you call runAlongPath() to prepare the path to run along :) When PATH_FOUND is returned, you may then call runAlongPath(). |
private PathManager.RunResult |
runAlongPath_EnteringLiftState(Triple agentLocation)
|
private PathManager.RunResult |
runAlongPath_ExitingLift(Triple agentLocation)
|
private PathManager.RunResult |
runAlongPath_InCenterOfTheLiftState(Triple agentLocation)
|
private PathManager.RunResult |
runAlongPath_PathRestartedState(Triple agentLocation)
|
private PathManager.RunResult |
runAlongPath_RunningToNavpointState(Triple agentLocation)
|
PathManager.RunResult |
runAlongPath()
method to follow smoothly desired path - list of navigation points obtained from game map can handle movers - wait on it until top and leave note that movers in the way are in this fashion: - LiftExit -> LiftCenter -> LiftExit so as agent is supposed to go up when he is supposed to go to LiftCenter (therefore is around first LiftExit) he waits for mover to be about his level and then goes on it, wait to level with second LiftExit and move on |
private void |
switchToNextNavPoint()
Changes runningToNavPointIndex, fromNavpoint = toNavPoint, toNavPoint = next navpoint (if there is any, otherwise null, path ended). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final long PATH_REQUEST_TIMEOUT
private static final int PATH_ID_START_COUNTER
protected java.util.HashMap<java.lang.String,java.util.ArrayList<NavPoint>> pathsFromGB
private boolean pathRequestSent
private int pathId
private Triple pathToLocation
private java.util.ArrayList<NavPoint> path
private long lastPathRequestSent
private GameMap gameMap
private AgentBody body
private java.util.logging.Logger log
private PathManager.RunAlongPathState runningState
private NavPoint fromNavPoint
private NavPoint toNavPoint
private NeighNav edge
private int runningToNavPointIndex
private java.lang.String logPrefix
private Mover myMover
private boolean waitingForLift
private long waitingForLiftStartedMillis
private boolean returningToLiftExit
private int liftAttempts
private double zCoordWhenLiftCenterReached
private java.util.List<Triple> agentLocationHistory
private long lastAgentLocationAddedMillis
private long lastJumpMillis
Constructor Detail |
---|
public PathManager(GameMap gameMap, AgentBody body, java.util.logging.Logger platformLog)
GameMap is needed for the PathManager to be able to use AStar.
Method Detail |
---|
public void restartPathManager()
public PathManager.PathResult retrievePathGB(Triple location)
When PATH_FOUND is returned, you may then call runAlongPath().
If NO_PATH is returned, the PathManager is restarted and you next call of this method will send another GETPATH command.
If called for different location then previous calls, the path manager is restarted and new GETPATH is sent.
If returning OBTAINING_PATH just keep calling this method with the same 'location' until it returns NO_PATH or PATH_FOUND.
location
-
public PathManager.PathResult retrievePathAStar(NavPoint target)
When PATH_FOUND is returned, you may then call runAlongPath().
If NO_PATH is returned, the AStar was unable to find a path from agent's current location.
target
-
public void receiveMessage(RcvMsgEvent e)
receiveMessage
in interface RcvMsgListener
public java.util.ArrayList<NavPoint> getPath()
public void restartRunAlongPath()
private double deviationFromTheRunningLine(Triple agentLocation)
private NavPoint getNavPointFromMemory(NavPoint np)
np
-
private void switchToNextNavPoint()
private NavPoint getNextNavPoint()
private PathManager.Lift isNavpointLift(NavPoint np)
public java.util.ArrayList<NavPoint> getPath(java.lang.String pathId)
pathId
-
private double maxDistanceInAgentLocationHistory()
private boolean isStucked()
private void jumpCheck(Triple agentLocation)
public PathManager.RunResult runAlongPath()
private PathManager.RunResult runAlongPath_PathRestartedState(Triple agentLocation)
private PathManager.RunResult runAlongPath_RunningToNavpointState(Triple agentLocation)
private Mover locateMover(Triple location)
private PathManager.RunResult runAlongPath_EnteringLiftState(Triple agentLocation)
private PathManager.RunResult runAlongPath_InCenterOfTheLiftState(Triple agentLocation)
private PathManager.RunResult runAlongPath_ExitingLift(Triple agentLocation)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |