@@ -87,7 +87,7 @@ def child_node(self, problem, action):
87
87
88
88
def solution (self ):
89
89
"Return the sequence of actions to go from the root to this node."
90
- return [node .action for node in self .path ()]
90
+ return [node .action for node in self .path ()[ 1 :] ]
91
91
92
92
def path (self ):
93
93
"Return a list of nodes forming the path from the root to this node."
@@ -806,22 +806,20 @@ def compare_graph_searchers():
806
806
807
807
__doc__ += """
808
808
>>> ab = GraphProblem('A', 'B', romania)
809
- >>> breadth_first_tree_search(ab).state
810
- 'B'
811
- >>> breadth_first_graph_search(ab).state
812
- 'B'
813
- >>> depth_first_graph_search(ab).state
814
- 'B'
815
- >>> iterative_deepening_search(ab).state
816
- 'B'
817
- >>> depth_limited_search(ab).state
818
- 'B'
819
- >>> astar_search(ab).state
820
- 'B'
821
- >>> recursive_best_first_search(ab).state
822
- 'B'
823
- >>> [node.state for node in astar_search(ab).path()]
824
- ['A', 'S', 'R', 'P', 'B']
809
+ >>> breadth_first_tree_search(ab).solution()
810
+ ['S', 'F', 'B']
811
+ >>> breadth_first_graph_search(ab).solution()
812
+ ['S', 'F', 'B']
813
+ >>> depth_first_graph_search(ab).solution()
814
+ ['T', 'L', 'M', 'D', 'C', 'R', 'S', 'F', 'B']
815
+ >>> iterative_deepening_search(ab).solution()
816
+ ['S', 'F', 'B']
817
+ >>> len(depth_limited_search(ab).solution())
818
+ 50
819
+ >>> astar_search(ab).solution()
820
+ ['S', 'R', 'P', 'B']
821
+ >>> recursive_best_first_search(ab).solution()
822
+ ['S', 'R', 'P', 'B']
825
823
826
824
>>> board = list('SARTELNID')
827
825
>>> print_boggle(board)
0 commit comments