From ad87b600801d236c1178a0c08c3f83799f53e259 Mon Sep 17 00:00:00 2001 From: DKE Date: Sat, 19 May 2018 19:37:38 +0200 Subject: [PATCH 1/3] 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:]] From 6a1130dffd5f4a57306614331b783489064461e2 Mon Sep 17 00:00:00 2001 From: DKE Date: Sat, 19 May 2018 19:50:49 +0200 Subject: [PATCH 2/3] Update search.py --- search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/search.py b/search.py index 2d2c0ccd9..24783d711 100644 --- a/search.py +++ b/search.py @@ -112,7 +112,7 @@ def child_node(self, problem, 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)) + action, next_state)) return next_node def solution(self): From 83a8673c77bcba4fd286d3b110a248ac6b140ea9 Mon Sep 17 00:00:00 2001 From: DKE Date: Sat, 19 May 2018 22:02:03 +0200 Subject: [PATCH 3/3] Update search.py --- search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/search.py b/search.py index 24783d711..e1efaf93b 100644 --- a/search.py +++ b/search.py @@ -110,7 +110,7 @@ def expand(self, problem): def child_node(self, problem, action): """[Figure 3.10]""" next_state = problem.result(self.state, action) - next_node = Node(next_node, self, action, + next_node = Node(next_state, self, action, problem.path_cost(self.path_cost, self.state, action, next_state)) return next_node