From bf53abc658b86f25711c0b3a568850bd25f01256 Mon Sep 17 00:00:00 2001 From: Gabriela Piekarska Date: Thu, 28 Apr 2022 14:47:35 +0200 Subject: [PATCH] Update 'board' --- board | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/board b/board index c187398..57f891c 100644 --- a/board +++ b/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__':