Skip to content

Latest commit

 

History

History
25 lines (20 loc) · 1.54 KB

And-Or-Graph-Search.md

File metadata and controls

25 lines (20 loc) · 1.54 KB

AND-OR-GRAPH-SEARCH

AIMA3e

function AND-OR-GRAPH-SEARCH(problem) returns a conditional plan, or failure
 OR-SEARCH(problem.INITIAL-STATE, problem, [])


function OR-SEARCH(state, problem, path) returns a conditional plan, or failure
if problem.GOAL-TEST(state) then return the empty plan
if state is on path then return failure
for each action in problem.ACTIONS(state) do
   plan ← AND-SEARCH(RESULTS(state,action), problem, [state | path])
   if planfailure then return [action | plan]
return failure


function AND-SEARCH(states, problem, path) returns a conditional plan, or failure
for each si in states do
   plani ← OR-SEARCH(si, problem, path)
   if plani = failure then return failure
return [if s1 then plan1 else if s2 then plan2 else ... if sn-1 then plann-1 else plann]


Figure ?? An algorithm for searching AND-OR graphs generated by nondeterministic environments. It returns a conditional plan that reaches a goal state in all circumstances. (The notations [x | l] refers to the list formed by adding object x to the front of list l).