-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSearchSolution.py
27 lines (22 loc) · 929 Bytes
/
SearchSolution.py
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
class SearchSolution:
def __init__(self, problem, search_method):
self.problem_name = str(problem)
self.search_method = search_method
self.path = []
self.nodes_visited = 0
self.cost = 0
def __str__(self):
string = "----\n"
string += "{:s}\n"
string += "attempted with search method {:s}\n"
if len(self.path) > 0:
string += "number of nodes visited: {:d}\n"
string += "solution length: {:d}\n"
string += "cost: {:d}\n"
string += "path: {:s}\n"
string = string.format(self.problem_name, self.search_method,
self.nodes_visited, len(self.path), self.cost, str(self.path))
else:
string += "no solution found after visiting {:d} nodes\n"
string = string.format(self.problem_name, self.search_method, self.nodes_visited)
return string