Advertisement
Guest User

reversi

a guest
Dec 5th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.68 KB | None | 0 0
  1. :- module(reversi, [verifyState/5]).
  2.  
  3. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  4.  
  5. verifyState(State,Player,NextPlayer,Board,OtherPlayer):-
  6.   show(Board),
  7.   (
  8.     State = win, !,                             % If Player win -> stop
  9.     nl, write('End of game : '),
  10.     write(Player), write(' win !'), nl, nl
  11.     ;
  12.     State = draw, !,                            % If draw -> stop
  13.     nl, write('End of game : '),
  14.     write(' draw !'), nl, nl
  15.     ;
  16.     % Else -> continue the game
  17.     play([NextPlayer, play, Board], OtherPlayer) % Else -> continue the game
  18.   ).
  19. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement