1515
1616
1717class ExecutionTimeException (Exception ):
18+ """
19+ Exception that gets thrown when a certain time has been exceeded.
20+ """
1821 def __init__ (self , message ):
1922 super (ExecutionTimeException , self ).__init__ (message )
2023
2124
2225class ExecutionRunsException (Exception ):
26+ """
27+ Exception that gets thrown when the number of max. runs has been reached.
28+ """
2329 def __init__ (self , message ):
2430 super (ExecutionRunsException , self ).__init__ (message )
2531
@@ -31,7 +37,7 @@ def __init__(self, heuristic=None, weight=1,
3137 time_limit = TIME_LIMIT ,
3238 max_runs = MAX_RUNS ):
3339 """
34- find shortest path
40+ Find shortest path
3541 :param heuristic: heuristic used to calculate distance of 2 points
3642 (defaults to manhattan)
3743 :param weight: weight for the edges
@@ -58,7 +64,7 @@ def __init__(self, heuristic=None, weight=1,
5864
5965 def apply_heuristic (self , node_a , node_b , heuristic = None , graph = None ):
6066 """
61- helper function to apply heuristic
67+ Helper function to apply heuristic
6268 """
6369 if not heuristic :
6470 heuristic = self .heuristic
@@ -84,15 +90,16 @@ def apply_heuristic(self, node_a, node_b, heuristic=None, graph=None):
8490
8591 def find_neighbors (self , grid , node , diagonal_movement = None ):
8692 '''
87- find neighbor, same for Djikstra, A*, Bi-A*, IDA*
93+ Find neighbor, same for Djikstra, A*, Bi-A*, IDA*
8894 '''
8995 if not diagonal_movement :
9096 diagonal_movement = self .diagonal_movement
9197 return grid .neighbors (node , diagonal_movement = diagonal_movement )
9298
9399 def keep_running (self ):
94100 """
95- check, if we run into time or iteration constrains.
101+ Check, if we run into time or iteration constrains.
102+
96103 :returns: True if we keep running and False if we run into a constraint
97104 """
98105 if self .runs >= self .max_runs :
@@ -109,7 +116,7 @@ def keep_running(self):
109116 def process_node (
110117 self , graph , node , parent , end , open_list , open_value = True ):
111118 '''
112- we check if the given node is part of the path by calculating its
119+ We check if the given node is part of the path by calculating its
113120 cost and add or remove it from our path
114121 :param node: the node we like to test
115122 (the neighbor in A* or jump-node in JumpPointSearch)
@@ -143,7 +150,7 @@ def process_node(
143150 def check_neighbors (self , start , end , graph , open_list ,
144151 open_value = True , backtrace_by = None ):
145152 """
146- find next path segment based on given node
153+ Find next path segment based on given node
147154 (or return path if we found the end)
148155
149156 :param start: start node
@@ -155,14 +162,14 @@ def check_neighbors(self, start, end, graph, open_list,
155162 'Please implement check_neighbors in your finder' )
156163
157164 def clean_grid (self , grid ):
158- """clean the map if needed."""
165+ """Clean the map if needed."""
159166 if grid .dirty :
160167 grid .cleanup ()
161168 grid .dirty = True
162169
163170 def find_path (self , start , end , grid ):
164171 """
165- find a path from start to end node on grid by iterating over
172+ Find a path from start to end node on grid by iterating over
166173 all neighbors of a node (see check_neighbors)
167174 :param start: start node
168175 :param end: end node
@@ -191,7 +198,7 @@ def find_path(self, start, end, grid):
191198
192199 def __repr__ (self ):
193200 """
194- return a human readable representation
201+ Return a human readable representation
195202 """
196203 return f"<{ self .__class__ .__name__ } " \
197204 f"diagonal_movement={ self .diagonal_movement } >"
0 commit comments