-
Notifications
You must be signed in to change notification settings - Fork 1
/
Node.java
64 lines (57 loc) · 1.1 KB
/
Node.java
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
public class Node{
private AStarState currentState;
private Node parent;
private double actualCost; // g(n)
private double heuristicCost; // heuristic cost / h(n)
private double fCost; // f(n)cost
/**
* Constructor for Node
*/
public Node(AStarState s){
currentState = s;
parent = null;
actualCost = 0;
heuristicCost = 0;
fCost = 0;
}
/**
* Constructor with parameters
*/
public Node(Node parent, AStarState s, double c, double h){
this.parent = parent;
currentState = s;
actualCost = c;
heuristicCost = h;
fCost = actualCost + heuristicCost;
}
/**
* returns the parent
*/
public Node getParent(){
return parent;
}
/**
* returns the value of currentState
*/
public AStarState getCurrentState(){
return currentState;
}
/**
* returns the actualCost g(n)
*/
public double getActualCost(){
return actualCost;
}
/**
* returns the heuristic cost
*/
public double getHeuristicCost(){
return heuristicCost;
}
/**
* returns the f(n) cost
*/
public double getFCost(){
return fCost;
}
}