Script started on Mon Mar 09 18:02:04 1998 metz[11]% cat hmwk5.pp /* Webber Homework #5 Dan Fraser (1219229) */ these_three_in_a_row(FIRST,SECOND,THIRD) :- square(ROW,left,FIRST), square(ROW,central,SECOND), square(ROW,right,THIRD). these_three_in_a_row(FIRST,SECOND,THIRD) :- square(upper,COL,FIRST), square(central,COL,SECOND), square(lower,COL,THIRD). these_three_in_a_row(FIRST,SECOND,THIRD) :- square(upper,left,FIRST), square(central,central,SECOND), square(lower,right,THIRD). these_three_in_a_row(FIRST,SECOND,THIRD) :- square(upper,right,FIRST), square(central,central,SECOND), square(lower,left,THIRD). status(won) :- these_three_in_a_row(x,x,x). status(lost) :- these_three_in_a_row(o,o,o), not these_three_in_a_row(x,x,x). status(win_this_move) :- these_three_in_a_row(x,x,unoccupied), not status(lost). status(win_this_move) :- these_three_in_a_row(x,unoccupied,x), not status(lost). status(win_this_move) :- these_three_in_a_row(unoccupied,x,x), not status(lost). status(am_forced) :- these_three_in_a_row(o,o,unoccupied), not status(win_this_move), not status(won). status(am_forced) :- these_three_in_a_row(o,unoccupied,o), not status(win_this_move), not status(won). status(am_forced) :- these_three_in_a_row(unoccupied,o,o), not status(win_this_move), not status(won). status(undecided) :- not status(won), not status(lost), not status(win_this_move), not status(am_forced). metz[12]% cat board1.pp /* This is an example of a tic tac toe board. It is also test case 1 for Homework 5. The meaning of the location constants are as follows: upper,left | upper,central | upper,right ------------------------------------- central,left | central,central | central,right ------------------------------------- lower,left | lower,central | lower,right You are x and the opponent is o. This particular board is: o | o | --------- x | x | --------- | | */ square(upper, left, o) :- . square(upper, central, o) :- . square(upper, right, unoccupied) :- . square(central, left, x) :- . square(central, central, x) :- . square(central, right, unoccupied) :- . square(lower, left, unoccupied) :- . square(lower, central, unoccupied) :- . square(lower, right, unoccupied) :- . metz[13]% pprolog hmwk5.pp board1.pp Welcome to picoProlog Reading hmwk5.pp Reading board1.pp # :- status(X). X = win_this_move ? no # :- ^D metz[14]% cat board2.pp /* This is an example of a tic tac toe board. It is also test case 1 for Homework 5. The meaning of the location constants are as follows: upper,left | upper,central | upper,right ------------------------------------- central,left | central,central | central,right ------------------------------------- lower,left | lower,central | lower,right You are x and the opponent is o. This particular board is: o | x | --------- x | o | --------- | | */ square(upper, left, o) :- . square(upper, central, x) :- . square(upper, right, unoccupied) :- . square(central, left, x) :- . square(central, central, o) :- . square(central, right, unoccupied) :- . square(lower, left, unoccupied) :- . square(lower, central, unoccupied) :- . square(lower, right, unoccupied) :- . metz[15]% pprolog hmwk5.pp board2.pp Welcome to picoProlog Reading hmwk5.pp Reading board2.pp # :- status(X). X = am_forced ? no # :- ^D metz[16]% cat board.pp /* This is an example of a tic tac toe board. It is also test case 1 for Homework 5. The meaning of the location constants are as follows: upper,left | upper,central | upper,right ------------------------------------- central,left | central,central | central,right ------------------------------------- lower,left | lower,central | lower,right You are x and the opponent is o. This particular board is: o | x | --------- x | o | o --------- | | x */ square(upper, left, o) :- . square(upper, central, x) :- . square(upper, right, unoccupied) :- . square(central, left, x) :- . square(central, central, o) :- . square(central, right, o) :- . square(lower, left, unoccupied) :- . square(lower, central, unoccupied) :- . square(lower, right, x) :- . metz[17]% pprolog hmwk5.pp board3.pp Welcome to picoProlog Reading hmwk5.pp Reading board3.pp # :- status(X). X = undecided ? no # :- ^D metz[18]% cat board4.pp /* This is an example of a tic tac toe board. It is also test case 1 for Homework 5. The meaning of the location constants are as follows: upper,left | upper,central | upper,right ------------------------------------- central,left | central,central | central,right ------------------------------------- lower,left | lower,central | lower,right You are x and the opponent is o. This particular board is: x | x | o --------- x | o | --------- o | | */ square(upper, left, x) :- . square(upper, central, x) :- . square(upper, right, o) :- . square(central, left, x) :- . square(central, central, o) :- . square(central, right, unoccupied) :- . square(lower, left, o) :- . square(lower, central, unoccupied) :- . square(lower, right, unoccupied) :- . metz[19]% pprolog hmwk5.pp board4.pp Welcome to picoProlog Reading hmwk5.pp Reading board4.pp # :- status(X). X = lost ? no # :- ^D metz[20]% cat board6.pp cat: cannot open board6.pp metz[21]% cat board5.pp /* This is an example of a tic tac toe board. It is also test case 1 for Homework 5. The meaning of the location constants are as follows: upper,left | upper,central | upper,right ------------------------------------- central,left | central,central | central,right ------------------------------------- lower,left | lower,central | lower,right You are x and the opponent is o. This particular board is: x | o | o --------- x | o | --------- x | | */ square(upper, left, x) :- . square(upper, central, o) :- . square(upper, right, o) :- . square(central, left, x) :- . square(central, central, o) :- . square(central, right, unoccupied) :- . square(lower, left, x) :- . square(lower, central, unoccupied) :- . square(lower, right, unoccupied) :- . metz[22]% pprolog hmwk5.pp board5.pp Welcome to picoProlog Reading hmwk5.pp Reading board5.pp # :- status(X). X = won ? no # :- ^D metz[23]% exit exit script done on Mon Mar 09 18:04:09 1998