Moved unused condition to its propper place.

This commit is contained in:
d3rped 2018-03-21 14:44:55 +01:00
parent 57d731409f
commit 7cff115075

View file

@ -68,7 +68,8 @@ class Planet:
''' '''
Returns a shortest path between two nodes. Returns a shortest path between two nodes.
Used Algorithm: Dijkstra's Algorithm, will be "replaced" by A* later Used Algorithm: Dijkstra's Algorithm
Have a look at heapqueue: https://docs.python.org/2/library/heapq.html
Formatting: Formatting:
List = [(total_len, (current_node, [((node), Direction)]))] List = [(total_len, (current_node, [((node), Direction)]))]
''' '''
@ -87,11 +88,10 @@ class Planet:
self.path_found.append(self.path_search[0][1][0]) self.path_found.append(self.path_search[0][1][0])
self.path_search.pop(0) self.path_search.pop(0)
if(self.path_search == []): # if map is empty if(self.path_search == []): # if map is empty
print("Destination is not reachable from start.")
break break
self.path_search.sort() self.path_search.sort()
if(self.path_search[0][1][0] == target): if(self.path_search[0][1][0] == target):
return self.path_search[0][1][1] return self.path_search[0][1][1]
else:
print("Destination is not reachable from start.")
else: else:
print("Cannot calculate shortest Path. Start or target is not in known.") print("Cannot calculate shortest Path. Start or target is not in known.")