astar #4
32
board
32
board
@ -172,6 +172,34 @@ class Node: #prawie jak Field w bfs
|
||||
self.action = action
|
||||
|
||||
|
||||
def succ1(state):
|
||||
successors = []#-90 obrót w lewo, +90 obrót w prawo
|
||||
print(state[0])#operujemy na 0, 90, 180, 270
|
||||
print(state[1])
|
||||
right = state[2] + 90
|
||||
successors.append((("turn", "right"), (state[0], state[1], right)))
|
||||
left = state[2] - 90
|
||||
successors.append((("turn", "left"), (state[0], state[1], left)))
|
||||
if state[2] == 360:
|
||||
state[2] = 0
|
||||
if state[2] == -90:
|
||||
state[2] = 270
|
||||
if (state[0], state[1]) not in black_list:#działa
|
||||
if state[2] == 0 and state[0] < 14:
|
||||
new_x = state[0]+1
|
||||
successors.append((("move forward"), (new_x, state[1], state[2])))
|
||||
elif state[2] == 90 and state[1] > 0:
|
||||
new_y = state[1]-1
|
||||
successors.append((("move forward"), (state[0], new_y, state[2])))
|
||||
elif state[2] == 180 and state[0] > 0:
|
||||
new_x = state[0]-1
|
||||
successors.append((("move forward"), (new_x, state[1], state[2])))
|
||||
elif state[2] == 270 and state[1] < 14:
|
||||
new_y = state[1]+1
|
||||
successors.append((("move forward"), (state[0], new_y, state[2])))
|
||||
return successors
|
||||
|
||||
|
||||
def algorithm():
|
||||
opened = PriorityQueue()#może być też lista
|
||||
closed = []#już odwiedzone, odrzucone wierzchołki
|
||||
@ -187,8 +215,8 @@ def algorithm():
|
||||
|
||||
a = final_state[0]
|
||||
b = final_state[1]
|
||||
hole = Hole("astar", Position(a, b))#narysowana dziura w miejscu mety(celu), by sprawdzić, czy działa
|
||||
objectArray.append(hole)
|
||||
#hole = Hole("astar", Position(a, b))#narysowana dziura w miejscu mety(celu), by sprawdzić, czy działa
|
||||
#objectArray.append(hole)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
Reference in New Issue
Block a user