public class ResolverUniformCostThread extends android.os.AsyncTask<Integer,HeuristicPathTree.Node,HeuristicPathTree>
Modifier and Type | Field and Description |
---|---|
private int |
actualStep |
private static String |
DOWN |
private ArrayList<HeuristicPathTree.Node> |
expandedNodes |
private ArrayList<String> |
expansionOrder |
private iUniformCost |
iMethods |
private boolean |
isPathFound |
private int |
lastX |
private int |
lastY |
private static String |
LEFT |
private HeuristicPathTree.Node[][] |
nodes |
private static String |
RIGHT |
private HeuristicPathTree |
tree |
private static String |
UP |
private long |
updateTime |
private HashSet<HeuristicPathTree.Node> |
visitedNodes |
Constructor and Description |
---|
ResolverUniformCostThread(HeuristicPathTree.Node[][] nodes,
ArrayList<String> expansionOrder,
long updateTime,
iUniformCost iMethods)
Constructor of the whole resolver for the Uniform Cost Thread.
|
Modifier and Type | Method and Description |
---|---|
protected HeuristicPathTree |
doInBackground(Integer... values)
In the background execution of the thread, we are actually executing the main algorithm.
|
private HeuristicPathTree.Node |
expandInDirection(String direction,
int y,
int x,
HashSet<HeuristicPathTree.Node> visitedNodes)
check if the direction in which the node is trying to be expanded is available or has any limitations.
|
private void |
getNodesNextStep(HeuristicPathTree.Node node,
ArrayList<HeuristicPathTree.Node> expandedNodes,
HashSet<HeuristicPathTree.Node> visitedNodes)
Expand the nodes correctly, according to the limitations of the map.
|
protected void |
onPostExecute(HeuristicPathTree heuristicPathTree)
Whenever the algorithm finishes, we have to finish the thread.
|
protected void |
onProgressUpdate(HeuristicPathTree.Node... values)
Every time the thread refreshes, we have to move the character in the UI.
|
private void |
setFitness(HeuristicPathTree.Node response,
HeuristicPathTree.Node Father)
Fitness method so we know which node to select each time.
|
private static final String DOWN
private static final String UP
private static final String LEFT
private static final String RIGHT
private ArrayList<HeuristicPathTree.Node> expandedNodes
private HashSet<HeuristicPathTree.Node> visitedNodes
private HeuristicPathTree.Node[][] nodes
private boolean isPathFound
private iUniformCost iMethods
private long updateTime
private HeuristicPathTree tree
private int lastY
private int lastX
private int actualStep
public ResolverUniformCostThread(HeuristicPathTree.Node[][] nodes, ArrayList<String> expansionOrder, long updateTime, iUniformCost iMethods)
nodes
- Heuristic nodes.expansionOrder
- Expansion order set by the user.updateTime
- Update time for the thread.iMethods
- Method, related to which algorithm is being used.protected HeuristicPathTree doInBackground(Integer... values)
doInBackground
in class android.os.AsyncTask<Integer,HeuristicPathTree.Node,HeuristicPathTree>
values
- Values related to the initial and final coordinates.protected void onProgressUpdate(HeuristicPathTree.Node... values)
onProgressUpdate
in class android.os.AsyncTask<Integer,HeuristicPathTree.Node,HeuristicPathTree>
values
- Values related to the position of the character.protected void onPostExecute(HeuristicPathTree heuristicPathTree)
onPostExecute
in class android.os.AsyncTask<Integer,HeuristicPathTree.Node,HeuristicPathTree>
heuristicPathTree
- Tree to process.private void getNodesNextStep(HeuristicPathTree.Node node, ArrayList<HeuristicPathTree.Node> expandedNodes, HashSet<HeuristicPathTree.Node> visitedNodes)
node
- Node to be processed.expandedNodes
- Expanded nodes list so we dont repeat.visitedNodes
- Visited nodes list so we dont repeat.private void setFitness(HeuristicPathTree.Node response, HeuristicPathTree.Node Father)
response
- Node to process.private HeuristicPathTree.Node expandInDirection(String direction, int y, int x, HashSet<HeuristicPathTree.Node> visitedNodes)
direction
- Direction to be expanded.y
- Y coordinate of the actual node.x
- X coordinate of the actual node.visitedNodes
- Visited nodes list so we dont repeat.