Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3a4f419

Browse files
committed
Cleanup in search.py.
1 parent ed96027 commit 3a4f419

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

search.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def successor(self, state):
3434

3535
def goal_test(self, state):
3636
"""Return True if the state is a goal. The default method compares the
37-
state to self.goal, as specified in the constructor. Implement this
37+
state to self.goal, as specified in the constructor. Override this
3838
method if checking against a single self.goal is not enough."""
3939
return state == self.goal
4040

@@ -725,10 +725,7 @@ def goal_test(self, state):
725725
return result
726726

727727
def __getattr__(self, attr):
728-
if attr in ('succs', 'goal_tests', 'states'):
729-
return self.__dict__[attr]
730-
else:
731-
return getattr(self.problem, attr)
728+
return getattr(self.problem, attr)
732729

733730
def __repr__(self):
734731
return '<%4d/%4d/%4d/%s>' % (self.succs, self.goal_tests,
@@ -748,7 +745,7 @@ def do(searcher, problem):
748745
def compare_graph_searchers():
749746
"""Prints a table of results like this:
750747
>>> compare_graph_searchers()
751-
Searcher Romania(A,B) Romania(O, N) Australia
748+
Searcher Romania(A, B) Romania(O, N) Australia
752749
breadth_first_tree_search < 21/ 22/ 59/B> <1158/1159/3288/N> < 7/ 8/ 22/WA>
753750
breadth_first_graph_search < 10/ 19/ 26/B> < 19/ 45/ 45/N> < 5/ 8/ 16/WA>
754751
depth_first_graph_search < 9/ 15/ 23/B> < 16/ 27/ 39/N> < 4/ 7/ 13/WA>
@@ -759,7 +756,7 @@ def compare_graph_searchers():
759756
compare_searchers(problems=[GraphProblem('A', 'B', romania),
760757
GraphProblem('O', 'N', romania),
761758
GraphProblem('Q', 'WA', australia)],
762-
header=['Searcher', 'Romania(A,B)', 'Romania(O, N)', 'Australia'])
759+
header=['Searcher', 'Romania(A, B)', 'Romania(O, N)', 'Australia'])
763760

764761
#______________________________________________________________________________
765762

0 commit comments

Comments
 (0)