Moved unused condition to its propper place.
This commit is contained in:
parent
57d731409f
commit
7cff115075
1 changed files with 3 additions and 3 deletions
|
@ -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.")
|
||||||
|
|
Loading…
Reference in a new issue