- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHandler.py
More file actions
Latest commit
35 lines (29 loc) · 1.45 KB
/
Copy pathHandler.py
File metadata and controls
35 lines (29 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
fromsrc.MapProblemimportMapProblem
fromsrc.SearcherimportSearcher
classHandler:
def__init__(self, algorithm, adjacency_list, heuristic_dict, start, goal, graph_search):
self.algorithm=algorithm
self.adjacency_list=adjacency_list
self.heuristic_dict=heuristic_dict
self.start=start
self.goal=goal
self.graph_search=graph_search
defhandle(self):
possible_algorithms= ['dfs', 'bfs', 'a*', 'greedybestfirst', 'uniformcost']
ifself.heuristic_dictisNone:
possible_algorithms= ['dfs', 'bfs', 'uniformcost']
ifself.algorithm.lower() notinpossible_algorithms:
print('This algorithm is not possible for your inputs. Please specify the heuristics file')
exit(0)
mp=MapProblem(self.adjacency_list, self.heuristic_dict, self.start, self.goal)
searcher=Searcher()
ifself.algorithm.lower() =='dfs':
searcher.depth_first_search(mp, self.graph_search)
elifself.algorithm.lower() =='bfs':
searcher.breadth_first_search(mp, self.graph_search)
elifself.algorithm.lower() =='a*':
searcher.a_star_search(mp, self.graph_search)
elifself.algorithm.lower() =='greedybestfirst':
searcher.greedy_best_first_search(mp, self.graph_search)
elifself.algorithm.lower() =='uniformcost':
searcher.uniform_cost_search(mp, self.graph_search)