2022-04-07 00:55:36 +02:00
|
|
|
class Node:
|
|
|
|
def __init__(self, parent, action, state_array):
|
|
|
|
self.parent = parent
|
2022-04-16 00:11:24 +02:00
|
|
|
self.action = action
|
2022-04-07 00:55:36 +02:00
|
|
|
self.position = state_array
|
|
|
|
|
2022-04-16 00:11:24 +02:00
|
|
|
# if parent:
|
|
|
|
# parent_pos = parent[1].get_position()
|
|
|
|
# diff = [state_array[0] - parent_pos[0], state_array[1] - parent_pos[1]]
|
|
|
|
# if diff[0]==1:
|
|
|
|
# action="E"
|
|
|
|
# elif diff[0]==-1:
|
|
|
|
# action="W"
|
|
|
|
# elif diff[1]==1:
|
|
|
|
# action="S"
|
|
|
|
# elif diff[1]==-1:
|
|
|
|
# action="N"
|
|
|
|
# self.action=action
|
|
|
|
# else:
|
|
|
|
# self.action=action
|
2022-04-07 05:33:10 +02:00
|
|
|
|
2022-04-07 00:55:36 +02:00
|
|
|
def get_position(self):
|
|
|
|
return self.position
|
|
|
|
|
|
|
|
def get_action(self):
|
|
|
|
return self.action
|
|
|
|
|
|
|
|
def get_parent(self):
|
|
|
|
return self.parent
|
|
|
|
|
|
|
|
def set_parent(self, parent):
|
|
|
|
self.parent = parent
|
|
|
|
|
|
|
|
|