Class LayeredAreasNavigation<NodeId,Nav extends XPathfinder<NodeId> & CanDealWithDynamicObstacle<NodeId>>
java.lang.Object
eu.iv4xr.framework.extensions.pathfinding.LayeredAreasNavigation<NodeId,Nav>
- Type Parameters:
NodeId-Nav-
- All Implemented Interfaces:
CanDealWithDynamicObstacle<Pair<Integer,NodeId>>,Pathfinder2<Pair<Integer,NodeId>>,XPathfinder<Pair<Integer,NodeId>>
public class LayeredAreasNavigation<NodeId,Nav extends XPathfinder<NodeId> & CanDealWithDynamicObstacle<NodeId>>
extends Object
implements XPathfinder<Pair<Integer,NodeId>>, CanDealWithDynamicObstacle<Pair<Integer,NodeId>>
Support navigation over multiple areas, linearly stacked in layers. The areas are
numbered starting from 0. Each area is connected to the area before it through a
portal, and to the area next to it with another portal. The first and last areas
only have one portal.
- Author:
- Wish
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassRepresenting a bi-directional "portal" between areas. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) booleanPortals between areas. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddNextArea(Nav area, NodeId portalLow, NodeId portalHigh, boolean isOpen)Add a new area with index a, where a is the current number of areas we have.voidaddObstacle(Pair<Integer,NodeId> o)connectedHighPortal(int A)Return the high-portal of the next area, to which we will travel to if we take the A's low-portal.connectedLowPortal(int A)Return the low-portal of the previous area, to which we will travel from to teleport to A.Return a path from the start node to either a frontier-node or an unexplored node (the implementation decides this).Return a path between "from", to "to".Return frontier-nodes.booleanhasbeenSeen(Pair<Integer,NodeId> ndx)Check is the given node is marked as "has been seen".highPortal(int A)Return the high-portal of the given area A (this is the portal we travel to from the low-portal of the area previous to A).booleanisBlocking(Pair<Integer,NodeId> o)Return the state of this obstacle.lowPortal(int A)Return the low-portal of the given area A.voidmarkAsSeen(Pair<Integer,NodeId> ndx)Mark the given node as "has been seen".voidremoveObstacle(Pair<Integer,NodeId> o)voidsetBlockingState(Pair<Integer,NodeId> o, boolean isBlocking)Set the the state of this obstacle to blocking or unblocking.voidWhen true then the pathfinder will consider all nodes in the graph to have been seen.voidsetPortal(int areaFrom, int areaTo, boolean isOpen)Set the portal between area a1 and a2 to open or close.toString()booleanWhen true then the pathfinder will consider all nodes in the graph to have been seen.voidClear the marking of "has been seen".Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface eu.iv4xr.framework.extensions.pathfinding.CanDealWithDynamicObstacle
toggleBlockingOff, toggleBlockingOnMethods inherited from interface eu.iv4xr.framework.extensions.pathfinding.Pathfinder2
isReachableFromMethods inherited from interface eu.iv4xr.framework.extensions.pathfinding.XPathfinder
explore, markAsSeen
-
Field Details
-
areas
-
portals
Portals between areas. If P is the i-th Portal in the list, this P connects area i to i+1. P.lowPortal is a node in area i, and P.highPortal is a node in area i+1. From P.lowPortal we can travel to P.highPortal (which is in area i+1).Note that if there are n areas, we will only have n-1 portals, as the last area have no next-area to connect to.
-
perfect_memory_pathfinding
boolean perfect_memory_pathfinding
-
-
Constructor Details
-
LayeredAreasNavigation
public LayeredAreasNavigation()
-
-
Method Details
-
lowPortal
Return the low-portal of the given area A. -
connectedHighPortal
Return the high-portal of the next area, to which we will travel to if we take the A's low-portal. -
highPortal
Return the high-portal of the given area A (this is the portal we travel to from the low-portal of the area previous to A). -
connectedLowPortal
Return the low-portal of the previous area, to which we will travel from to teleport to A. -
setPortal
public void setPortal(int areaFrom, int areaTo, boolean isOpen)Set the portal between area a1 and a2 to open or close.- Parameters:
isOpen- If true will open the portal, else close it.
-
findPath
Description copied from interface:Pathfinder2Return a path between "from", to "to". The path is represented as a list, whose first element is the node "from", and its last element is "to". The method returns null if no path can be found between them.- Specified by:
findPathin interfacePathfinder2<NodeId>
-
addObstacle
- Specified by:
addObstaclein interfaceCanDealWithDynamicObstacle<NodeId>
-
removeObstacle
- Specified by:
removeObstaclein interfaceCanDealWithDynamicObstacle<NodeId>
-
setBlockingState
Description copied from interface:CanDealWithDynamicObstacleSet the the state of this obstacle to blocking or unblocking.- Specified by:
setBlockingStatein interfaceCanDealWithDynamicObstacle<NodeId>isBlocking- If true then the obstacle will be set to its blocking state, and else non-blocking.
-
markAsSeen
Description copied from interface:XPathfinderMark the given node as "has been seen".- Specified by:
markAsSeenin interfaceXPathfinder<NodeId>
-
hasbeenSeen
Description copied from interface:XPathfinderCheck is the given node is marked as "has been seen".- Specified by:
hasbeenSeenin interfaceXPathfinder<NodeId>
-
getFrontier
Description copied from interface:XPathfinderReturn frontier-nodes. A frontier is a seen node, with at least one neighbor which has not been seen yet (unexplored).- Specified by:
getFrontierin interfaceXPathfinder<NodeId>
-
explore
public List<Pair<Integer,NodeId>> explore(Pair<Integer,NodeId> startNode, Pair<Integer,NodeId> heuristicNode)Description copied from interface:XPathfinderReturn a path from the start node to either a frontier-node or an unexplored node (the implementation decides this). A frontier node is a node with at least one unexplored neighbor. Such a path should only traverse though explored nodes, except the last node which could be an unexplored node. It is up to the implementation to guarantee (or at least make effort for it) that the returned path is navigable. To help chosing which frontier or unexplored node to explore to, a 'heuristic node' is also given. The chosen exploration target is expected to be the closest one, among candidate targets, to the given heuristic node.- Specified by:
explorein interfaceXPathfinder<NodeId>
-
wipeOutMemory
public void wipeOutMemory()Description copied from interface:XPathfinderClear the marking of "has been seen". So, after this all nodes are again considered as has not been seen.- Specified by:
wipeOutMemoryin interfaceXPathfinder<NodeId>
-
usingPerfectMemoryPathfinding
public boolean usingPerfectMemoryPathfinding()Description copied from interface:XPathfinderWhen true then the pathfinder will consider all nodes in the graph to have been seen.- Specified by:
usingPerfectMemoryPathfindingin interfaceXPathfinder<NodeId>
-
setPerfectMemoryPathfinding
Description copied from interface:XPathfinderWhen true then the pathfinder will consider all nodes in the graph to have been seen.- Specified by:
setPerfectMemoryPathfindingin interfaceXPathfinder<NodeId>
-
isBlocking
Description copied from interface:CanDealWithDynamicObstacleReturn the state of this obstacle. True means that it is in the blocking state.- Specified by:
isBlockingin interfaceCanDealWithDynamicObstacle<NodeId>
-
toString