@@ -63,7 +63,7 @@ def init_map(self):
6363 map_list .append (tmp )
6464 return map_list
6565
66- def get_neighbers (self , state ):
66+ def get_neighbors (self , state ):
6767 state_list = []
6868 for i in [- 1 , 0 , 1 ]:
6969 for j in [- 1 , 0 , 1 ]:
@@ -99,18 +99,18 @@ def process_state(self):
9999 self .remove (x )
100100
101101 if k_old < x .h :
102- for y in self .map .get_neighbers (x ):
102+ for y in self .map .get_neighbors (x ):
103103 if y .h <= k_old and x .h > y .h + x .cost (y ):
104104 x .parent = y
105105 x .h = y .h + x .cost (y )
106106 elif k_old == x .h :
107- for y in self .map .get_neighbers (x ):
107+ for y in self .map .get_neighbors (x ):
108108 if y .t == "new" or y .parent == x and y .h != x .h + x .cost (y ) \
109109 or y .parent != x and y .h > x .h + x .cost (y ):
110110 y .parent = x
111111 self .insert (y , x .h + x .cost (y ))
112112 else :
113- for y in self .map .get_neighbers (x ):
113+ for y in self .map .get_neighbors (x ):
114114 if y .t == "new" or y .parent == x and y .h != x .h + x .cost (y ):
115115 y .parent = x
116116 self .insert (y , x .h + x .cost (y ))
@@ -178,7 +178,7 @@ def run(self, start, end):
178178 rx .append (tmp .x )
179179 ry .append (tmp .y )
180180 if show_animation :
181- plt .plot (rx , ry )
181+ plt .plot (rx , ry , "-r" )
182182 plt .pause (0.01 )
183183 if tmp .parent .state == "#" :
184184 self .modify (tmp )
@@ -226,14 +226,15 @@ def main():
226226 plt .plot (ox , oy , ".k" )
227227 plt .plot (start [0 ], start [1 ], "og" )
228228 plt .plot (goal [0 ], goal [1 ], "xb" )
229+ plt .axis ("equal" )
229230
230231 start = m .map [start [0 ]][start [1 ]]
231232 end = m .map [goal [0 ]][goal [1 ]]
232233 dstar = Dstar (m )
233234 rx , ry = dstar .run (start , end )
234235
235236 if show_animation :
236- plt .plot (rx , ry )
237+ plt .plot (rx , ry , "-r" )
237238 plt .show ()
238239
239240
0 commit comments