# And-Or Graphs CSCE 580 Spr03 Instructor: Marco Valtorta Hrishikesh J. Goradia Seang-Chan Ryu.

## Presentation on theme: "And-Or Graphs CSCE 580 Spr03 Instructor: Marco Valtorta Hrishikesh J. Goradia Seang-Chan Ryu."— Presentation transcript:

And-Or Graphs CSCE 580 Spr03 Instructor: Marco Valtorta Hrishikesh J. Goradia Seang-Chan Ryu

And-Or Graphs Technique for solving problems that can be decomposed into sub problems Links between nodes indicates relations between problems Or node: one of its successor node has to be solved And node: all of its successor node has to be solved Problem can be specified by two thinks: start node, goal nodes. Goal nodes: trivial (or primitive) problems Cost can be attached to arcs or nodes

And-Or Graphs Difference between state-state representation and and or representation. solution: path vs. tree

Search in and-or graphs a b c e hi dgf

Use Prolog’s own search mechanism –Only get answer yes or no not solution graph. –Hard to extend to use cost as well –Infinite loop if there is a cycle a :- b. a :- c. b :- d, e. e :- h. c :- f, g. f :- h, i. d. g. h.

Search in and-or graphs Other representation :- op (600, xfx, --->). :- op (500, xfx, :). a ---> or : [b,c]. b ---> and : [d,e]. c ---> and : [f,g]. e ---> or : [h]. f ---> or : [h,i]. goal( d). goal( g). goal( h).

Search in and-or graphs Depth first search. Modification of depth first search (restricting with maximum depth) – andor.pl Iterative deepening. (increase the maximum depth as the search goes along).

Applying and-or graphs Adversarial situations, such as game playing, can often be represented as and-or trees –Nodes represent the situation –Arcs represent possible actions for each player –Each path represents the sequence of choices made alternately by the two opponents In the case of game trees, one is interested in a winning strategy.

Tic-tac-toe game Max size of the state space for a complete solution = 9!

Tic-tac-toe game For pragmatic reasons, we will consider a subset of the tic-tac-toe problem. The adjacent figure shows the initial state of our tic-tac-toe program. Max. state space for our new problem = 4!

Tic-tac-toe game The winning positions (shown in red) are the goal states. tictactoe.pl shows the complete Prolog code for our problem. tictactoe.pl

Final comments… For use in real-world applications, the AND-OR graphs technique computes the best state instead of a complete path to the terminal state. These graphs use minmax search and are called game trees. The AND-OR technique for searching can be easily extended to accommodate cost in the graph problems