Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def is_invalid_position(maze, node):
- found_in_list = False
- for node in nodes:
- if new_node == node and new_node.distance_from_start > node.distance_from_start:
- found_in_list = True
- break
- if (found_in_list):
- continue
- nodes.append(new_node)
- new_node = Node(node_position, current_node)
- if (is_invalid_position(maze, new_node)):
- continue
- if (visited_nodes[new_node.position]):
- continue
- new_node.distance_from_target = get_squared_distance(new_node, end_node)
- new_node.cost = new_node.distance_from_start + new_node.distance_from_target
- while len(nodes) > 0:
- ...
- if current_node == end_node:
- return get_path_from_node(current_node)
- ...
- return []
- current_index = 0
- for index in range(len(nodes)):
- if nodes[index].cost < nodes[current_index].cost:
- current_index = index
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement