def _get_unvisited_neighbors(self, x, y): to_open = Fheap() if y > 1 and self.nodes[(x, y - 1)].state == NodeState.UNKNOWN: to_open.insert(self.nodes[(x, y - 1)]) if x < self.col_count and self.nodes[(x + 1, y)].state == NodeState.UNKNOWN: to_open.insert(self.nodes[(x + 1, y)]) if y < self.row_count and self.nodes[(x, y + 1)].state == NodeState.UNKNOWN: to_open.insert(self.nodes[(x, y + 1)]) if x > 1 and self.nodes[(x - 1, y)].state == NodeState.UNKNOWN: to_open.insert(self.nodes[(x - 1, y)]) return to_open
if check(((x - 1, y - 1))): adj.append(((x - 1, y - 1))) return adj queue = Fheap() node_dict = {} for y in range(n): for x in range(m): if y == source[1] and x == source[0]: node = Node(destination[1], destination[0], x, y, 0, option) node.val = 0 queue.insert(node) node_dict.update({(x, y): node}) elif maze[y][x] != 0: node = Node(destination[1], destination[0], x, y, infinity, option) queue.insert(node) node_dict.update({(x, y): node}) is_visited = [[False for x in range(m)] for y in range(n)] while True: node = queue.extract_min() is_visited[node.y][node.x] = True if node == node_dict[(m - 1, n - 1)]: break