@@ -47,13 +47,13 @@ class AStarQueue:
4747 A* Queue.
4848 """
4949
50- def __init__ (self ):
50+ def __init__ (self ) -> None :
5151 self .myheap = []
5252
5353 def show (self ):
5454 return self .myheap
5555
56- def push (self , priority , distance , node ):
56+ def push (self , priority , distance , node ) -> None :
5757 heapq .heappush (self .myheap , (priority , distance , node ))
5858
5959 def pop (self ):
@@ -67,13 +67,13 @@ class PriorityQueue:
6767 Priority Queue.
6868 """
6969
70- def __init__ (self ):
70+ def __init__ (self ) -> None :
7171 self .myheap = []
7272
7373 def show (self ):
7474 return self .myheap
7575
76- def push (self , priority , node ):
76+ def push (self , priority , node ) -> None :
7777 heapq .heappush (self .myheap , (priority , node ))
7878
7979 def pop (self ):
@@ -87,14 +87,14 @@ class PrioritySet:
8787 Create a priority queue that doesn't add duplicate nodes.
8888 """
8989
90- def __init__ (self ):
90+ def __init__ (self ) -> None :
9191 self .myheap = []
9292 self .myset = set ()
9393
9494 def show (self ):
9595 return self .myheap
9696
97- def push (self , priority , node ):
97+ def push (self , priority , node ) -> None :
9898 if node not in self .myset :
9999 heapq .heappush (self .myheap , (priority , node ))
100100 self .myset .add (node )
@@ -1074,7 +1074,7 @@ def _clear_visited(self) -> None:
10741074 self ._grid [row ][column ].update (is_visited = False , is_path = False )
10751075 self ._update_gui ()
10761076
1077- def _update_path (self ) -> bool | _MazeType :
1077+ def _update_path (self ) -> bool :
10781078 """
10791079 Updates the path.
10801080 """
@@ -1403,11 +1403,14 @@ def _xfs(
14031403 # Trace back to start using path_dict
14041404 path_node = goal_node
14051405 while True :
1406- path_node = path_dict [path_node ]
1407- mazearray [path_node [0 ]][path_node [1 ]].update (is_path = True ) # type: ignore
1408- self ._draw_square (mazearray , path_node [0 ], path_node [1 ]) # type: ignore
1406+ parent = path_dict [path_node ]
1407+ if parent is None :
1408+ break
1409+ path_node = parent
1410+ mazearray [path_node [0 ]][path_node [1 ]].update (is_path = True )
1411+ self ._draw_square (mazearray , path_node [0 ], path_node [1 ])
14091412 if self ._visualize :
1410- self ._update_square (path_node [0 ], path_node [1 ]) # type: ignore
1413+ self ._update_square (path_node [0 ], path_node [1 ])
14111414 if path_node == start_point :
14121415 return True
14131416
0 commit comments