|
1 | 1 | # DEPTH-LIMITED-SEARCH
|
2 | 2 |
|
| 3 | +## AIMA4e |
| 4 | + |
| 5 | +__function__ DEPTH-LIMITED-SEARCH(_problem_, _l_) __returns__ a solution, or failure, or cutoff |
| 6 | + _frontier_ ← a FIFO queue initially containing one path, for the _problem_'s initial state |
| 7 | + _solution_ ← failure |
| 8 | + __while__ _frontier_ is not empty __do__ |
| 9 | +   _parent_ ← pop(_frontier_) |
| 10 | +   __if__ depth(_parent_) > l __then__ |
| 11 | +     _solution_ ← cutoff |
| 12 | +     __else__ |
| 13 | +       __for__ _child_ __in__ successors(_parent_) __do__ |
| 14 | +         __if__ _child_ is a goal __then__ |
| 15 | +           __return__ _child_ |
| 16 | +         add _child_ to __frontier__ |
| 17 | + __return__ _solution_ |
| 18 | + |
| 19 | +--- |
| 20 | +__Figure 3.14__ An implementation of depth-limited tree search. The algorithm has two dif- |
| 21 | +ferent ways to signal failure to find a solution: it returns failure when it has exhausted all |
| 22 | +paths and proved there is no solution at any depth, and returns cutoff to mean there might be |
| 23 | +a solution at a deeper depth than l. Note that this algorithm does not keep track of reached |
| 24 | +states, and thus might visit the same state multiple times on different paths. |
| 25 | + |
3 | 26 | ## AIMA3e
|
4 | 27 | __function__ DEPTH-LIMITED-SEARCH(_problem_,_limit_) __returns__ a solution, or failure/cutoff
|
5 | 28 |  __return__ RECURSIVE\-DLS(MAKE\-NODE(_problem_.INITIAL\-STATE),_problem_,_limit_)
|
|
0 commit comments