Skip to content

Commit 1455dd1

Browse files
committed
Return None if path is not solvable
1 parent fd2119f commit 1455dd1

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

‎py2d/Navigation.py‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,27 @@ def get_path_rec(i,j):
109109
return []
110110

111111
d = self.get_data(i,j)[1]
112+
112113
if d == j:
113114
return [j]
115+
116+
elif d == None:
117+
return None
118+
114119
else:
115120
return get_path_rec(i,d) + get_path_rec(d,j)
116121

117122
i = self._polygons.index(start)
118123
j = self._polygons.index(stop)
119124

120-
out = [i] + get_path_rec(i,j)
125+
path = get_path_rec(i,j)
126+
127+
if path == None:
128+
return None
129+
130+
path = [i] + path
121131

122-
return NavPath(self, [self._polygons[i] for i in out])
132+
return NavPath(self, [self._polygons[p] for p in path])
123133

124134
def get_data(self, i, j):
125135
return self._nav_data[i][j]

0 commit comments

Comments
 (0)