From ad87b600801d236c1178a0c08c3f83799f53e259 Mon Sep 17 00:00:00 2001 From: DKE Date: Sat, 19 May 2018 19:37:38 +0200 Subject: [PATCH] Added a line to child node `child_node` method of `Node` uses the `problem.result` which returns normally a state not a node according to its docstring in `Problem`. Naming the variable `next_node` can be confusing to users when it actually refers to a resulting state. --- search.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/search.py b/search.py index 8094aa284..2d2c0ccd9 100644 --- a/search.py +++ b/search.py @@ -109,11 +109,12 @@ def expand(self, problem): def child_node(self, problem, action): """[Figure 3.10]""" - next_node = problem.result(self.state, action) - return Node(next_node, self, action, + next_state = problem.result(self.state, action) + next_node = Node(next_node, self, action, problem.path_cost(self.path_cost, self.state, action, next_node)) - + return next_node + def solution(self): """Return the sequence of actions to go from the root to this node.""" return [node.action for node in self.path()[1:]]