Skip to content

Commit 948e5d7

Browse files
authored
Update Tree-Search-and-Graph-Search.md
1 parent 5857d8c commit 948e5d7

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

md/Tree-Search-and-Graph-Search.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,27 @@ __function__ GRAPH-SEARCH(_problem_) __returns__ a solution, or failure
99
 _solution_ ← failure
1010
 __while__ _frontier_ is not empty __and__ _solution_ can possibly be improved __do__
1111
   _parent_ ← some node that we choose to remove from _frontier_
12-
   __for__ _child_ __in__ Expand(_parent_) __do__
12+
   __for__ _child_ __in__ EXPAND(_parent_) __do__
1313
     _s_ ← _child_.state
1414
     __if__ _s_ is not in _reached_ __or__ _child_ is a cheaper path than _reached_[_s_] __then__
1515
       _reached_[_s_] ← _child_
1616
       add _child_ to _frontier_
17-
       __if__ _child_ is a goal and is cheaper than _solution_ __then__
17+
       __if__ _s_ is a goal and _child_ is cheaper than _solution_ __then__
1818
         _solution_ = _child_
1919
 __return__ _solution_
2020

2121
---
22-
__Figure__ ?? In the GENERIC-SEARCH algorithm, we keep track of the best _solution_ found so far, as well as a set of states that we have already _reached_, and a _frontier_ of paths from which we will choose
22+
__function__ EXPAND(_problem, parent_) __returns__ a list of nodes
23+
 _s_ ← _parent_.state
24+
 _nodes_ ← an empty list
25+
 __for__ _action_ __in__ _problem_.actions(_s_) __do__
26+
   _s'_ ← _problem_.result(_s_, _action_)
27+
   _cost_ ← _parent_.path-cost + _problem_.step-cost(_s, action, s')
28+
   add _node_ to _nodes_
29+
 __return__ _nodes_
30+
31+
---
32+
__Figure__ ?? In the GRAPH-SEARCH algorithm, we keep track of the best _solution_ found so far, as well as the states that we have already _reached_, and a _frontier_ of paths from which we will choose
2333
the next path to expand.
2434
In any specific search algorithm, we specify (1) the criteria for ordering the paths in the frontier,
2535
and (2) the procedure for determining when it is no longer possible to improve on a solution.

0 commit comments

Comments
 (0)