-
Notifications
You must be signed in to change notification settings - Fork 0
/
node.py
35 lines (24 loc) · 1020 Bytes
/
node.py
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
#Class to define a tree node contents
class node:
def __init__(self, state, hash, cost_to_come, cost_to_go) -> None:
"""Constructor for node object
Args:
state (numpy array): state of the environemtn
"""
# an unique id is generated for the given state by taking the
# numpy array ordered elements in sequence
self.Node_hash = hash
#node's parent id
# contains "None" if the node is top of the tree
self.Parent_Node_hash = None
#Contains state that this node represents
self.Node_State = state
#Contains action taken by agent to reach the state
self.TRANSITION_ACTION = "START"
#Contains cost-to-come to the node
self.Cost_to_Come = cost_to_come
#Contains cost-to-Go to the goal
self.Cost_to_Go = cost_to_go
#Funciton to help heapq for comparing two node objects
def __lt__(self, other):
return self.Cost_to_Come < other.Cost_to_Come