-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.java
More file actions
66 lines (54 loc) · 1.11 KB
/
Copy pathNode.java
File metadata and controls
66 lines (54 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import java.util.LinkedList;
import java.util.List;
public class Node {
private int x;
private int y;
private int hCost;
private int fCost;
private Node parent;
private int gCost;
private List<Node> neighbors = new LinkedList<Node>();
/**
* Creates a node for the A* search
* @param x the x coordinate
* @param y the y coordinate
* @param totalCost the g(n) cost from the parent node
* @param hCost the heuristic cost from the
* @param parent the parent of the Node
*/
public Node(int x, int y, int totalCost, int hCost, Node parent) {
this.x = x;
this.y = y;
this.gCost = totalCost;
this.parent = parent;
this.hCost = hCost;
fCost = gCost + hCost;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public Node getParent() {
return parent;
}
public int gethCost() {
return hCost;
}
public int getfCost() {
return fCost;
}
public int getgCost() {
return gCost;
}
public List<Node> getNeighbors() {
return neighbors;
}
public void setNeighbors(List<Node> nodes) {
neighbors.clear();
for (Node n : nodes) {
neighbors.add(n);
}
}
}