Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. def is_invalid_position(maze, node):
  2.  
  3. found_in_list = False
  4. for node in nodes:
  5. if new_node == node and new_node.distance_from_start > node.distance_from_start:
  6. found_in_list = True
  7. break
  8.  
  9. if (found_in_list):
  10. continue
  11. nodes.append(new_node)
  12.  
  13. new_node = Node(node_position, current_node)
  14. if (is_invalid_position(maze, new_node)):
  15. continue
  16.  
  17. if (visited_nodes[new_node.position]):
  18. continue
  19.  
  20. new_node.distance_from_target = get_squared_distance(new_node, end_node)
  21. new_node.cost = new_node.distance_from_start + new_node.distance_from_target
  22.  
  23. while len(nodes) > 0:
  24. ...
  25.  
  26. if current_node == end_node:
  27. return get_path_from_node(current_node)
  28.  
  29. ...
  30.  
  31. return []
  32.  
  33. current_index = 0
  34. for index in range(len(nodes)):
  35. if nodes[index].cost < nodes[current_index].cost:
  36. current_index = index
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement