Question: Starting with the tic-tac-toe program of Figure 12.4, draw a directed acyclic graph in which every clause is a node and an arc from A

Starting with the tic-tac-toe program of Figure 12.4, draw a directed acyclic graph in which every clause is a node and an arc from A to B indicates that it is important, either for correctness or efficiency, that A come before B in the program. (Do not draw any other arcs.) Any topological sort of your graph should constitute an equally efficient version of the program. (Is the existing program one of them?)

Figure 12.4:

printsquare (N) :- o(N), write(' o '). printsquare (N) :- x(N), write('printsquare (N) :- o(N), write(' o '). printsquare (N) :- x(N), write(' x '). printsquare (N) :- empty (N), write(' printboard :- printsquare(1), printsquare (2), printsquare (3), nl, '). printsquare (4), printsquare(5), printsquare(6), nl, printsquare (7), printsquare(8), printsquare (9), nl. clear :- retractall (x(_)), retractall(o(_)). % main goal: play clear,

printsquare (N) :- o(N), write(' o '). printsquare (N) :- x(N), write(' x '). printsquare (N) :- empty (N), write(' printboard :- printsquare(1), printsquare (2), printsquare (3), nl, '). printsquare (4), printsquare(5), printsquare(6), nl, printsquare (7), printsquare(8), printsquare (9), nl. clear :- retractall (x(_)), retractall(o(_)). % main goal: play clear, repeat, getmove, respond. respond :- ordered_line (A, B, C), o(A), o(B), o(C), % shouldn't ever happen! printboard, write('You won.'), nl. :- makemove, printboard, done. respond

Step by Step Solution

3.41 Rating (167 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To create a directed acyclic graph DAG of the given tictactoe program we need to identify the dependencies between the clauses where a dependency mean... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Language Pragmatics Questions!