Catalano.Graph.Pathfinding.AStar
Class AStar
- java.lang.Object
-
- Catalano.Graph.Pathfinding.AStar.AStar
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classAStar.Heuristicstatic classAStar.Neighbor
-
Constructor Summary
Constructors Constructor and Description AStar(double[][] costMap)Initializes a new instance of the AStar class.AStar(double[][] costMap, AStar.Neighbor neighbor, AStar.Heuristic heuristic)Initializes a new instance of the AStar class.AStar(int width, int height)Initializes a new instance of the AStar class.AStar(int width, int height, double initialCost)Initializes a new instance of the AStar class.AStar(int width, int height, double initialCost, AStar.Neighbor neighbor, AStar.Heuristic heuristic)Initializes a new instance of the AStar class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddBlock(int x, int y)Add block in the path.java.util.ArrayList<IntPoint>FindPath(int startX, int startY, int endX, int endY)Find path.java.util.ArrayList<IntPoint>FindPath(IntPoint start, IntPoint end)Find path.doublegetCost(int x, int y)Get cost from a point.intgetHeight()Get height of the map.AStar.HeuristicgetHeuristic()Get heuristic.AStar.NeighborgetNeighbor()Get neighbor size of the algorithm.NodeMapgetNodeMap()Get node map.doublegetTotalCost(java.util.ArrayList<IntPoint> path)Get total cost.intgetWidth()Get width of the map.booleanisBlocked(int x, int y)Verify if the actual node is blocked.voidremoveBlock(int x, int y)Remove block in the path.voidsetCost(int x, int y, double cost)Set cost.voidsetHeuristic(AStar.Heuristic heuristic)Set heuristic.voidsetNeighbor(AStar.Neighbor neighbor)Set neighbor size of the algorithm.
-
-
-
Constructor Detail
-
AStar
public AStar(int width, int height)Initializes a new instance of the AStar class.- Parameters:
width- Width of the Matrix.height- Height of the Matrix.
-
AStar
public AStar(int width, int height, double initialCost)Initializes a new instance of the AStar class.- Parameters:
width- Width of the Matrix.height- Height of the Matrix.initialCost- Initial cost for all nodes.
-
AStar
public AStar(double[][] costMap)
Initializes a new instance of the AStar class.- Parameters:
costMap- Cost map.
-
AStar
public AStar(double[][] costMap, AStar.Neighbor neighbor, AStar.Heuristic heuristic)Initializes a new instance of the AStar class.- Parameters:
costMap- Cost map.neighbor- Neighbor.heuristic- Heuristic.
-
AStar
public AStar(int width, int height, double initialCost, AStar.Neighbor neighbor, AStar.Heuristic heuristic)Initializes a new instance of the AStar class.- Parameters:
width- Width of the matrix.height- Height of the matrix.initialCost- Initial cost for all the nodes.neighbor- Neighbor.heuristic- Heuristic.
-
-
Method Detail
-
getWidth
public int getWidth()
Get width of the map.- Returns:
- Width.
-
getHeight
public int getHeight()
Get height of the map.- Returns:
- Height.
-
getNeighbor
public AStar.Neighbor getNeighbor()
Get neighbor size of the algorithm.- Returns:
- Neighbor.
-
setNeighbor
public void setNeighbor(AStar.Neighbor neighbor)
Set neighbor size of the algorithm.- Parameters:
neighbor- Neighbor.
-
getHeuristic
public AStar.Heuristic getHeuristic()
Get heuristic.- Returns:
- Heuristic.
-
setHeuristic
public void setHeuristic(AStar.Heuristic heuristic)
Set heuristic.- Parameters:
heuristic- Heuristic.
-
addBlock
public void addBlock(int x, int y)Add block in the path. Is the same with the cust of the node equals zero.- Parameters:
x- X axis coordinate.y- Y axis coordinate.
-
removeBlock
public void removeBlock(int x, int y)Remove block in the path. Is the same with the cust of the node equals one.- Parameters:
x- X axis coordinate.y- Y axis coordinate.
-
isBlocked
public boolean isBlocked(int x, int y)Verify if the actual node is blocked.- Parameters:
x- X axis coordinate.y- Y axis coordinate.- Returns:
- True if is blocked, otherwise false.
-
getCost
public double getCost(int x, int y)Get cost from a point.- Parameters:
x- X axis coordinate.y- Y axis coordinate.- Returns:
- Cost.
-
setCost
public void setCost(int x, int y, double cost)Set cost.- Parameters:
x- X axis coordinate.y- Y axis coordinate.cost- Cost.
-
getNodeMap
public NodeMap getNodeMap()
Get node map.- Returns:
- Node map.
-
getTotalCost
public double getTotalCost(java.util.ArrayList<IntPoint> path)
Get total cost.- Parameters:
path- List of the points.- Returns:
- Total cost.
-
FindPath
public java.util.ArrayList<IntPoint> FindPath(IntPoint start, IntPoint end)
Description copied from interface:ISearchFind path.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG