/* finin@Umbc.edu, 2001, 2006


*/


:- ensure_loaded(mm).

play :-
  printGameIntro,
  start(S),
  showState(S),
  play(S).

% the game is over if someone has won.
play(S) :-
  player(P,_,_),
  win(P,S),
  format("Player ~p has won.\n",[P]).

  % the game is over if it's a draw
play(S) :-
  draw(S),
  format("The game has ended in a draw.\n",[]).

% chose the best move and continue playing from there.
play(S) :-
  S=s(Pnum,_),
  player(Pnum,Depth,Eval),
  mm(Depth,Eval,S,S2,_),
  showState(S2),
  play(S2).
	
showState(s(Player,Board)) :-
  format("~p's move.\n",[Player]),
  printBoard(Board) -> true | defaultPrintBoard(Board).

defaultPrintBoard(B) :-  format(" ~p\n",[B]).
