Advertisement
alexarcan

probl1_test2

May 26th, 2016
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.67 KB | None | 0 0
  1. game_winner([],_).
  2.  
  3. game_winner(Game,Res):-  %sau game_winner([Player1,Player2],Res)
  4.     nth0(0,Game,Player1),
  5.     nth0(1,Game,Player2),
  6.     condition(Player1,Player2,Res).
  7.  
  8. condition(L1,L2,Result):-
  9.     nth0(1,L1,Option1),
  10.     nth0(1,L2,Option2),
  11.     (   (  
  12.      (   Option1='R', Option2='S',Result=L1);
  13.      (   Option1='S', Option2='P',Result=L1);
  14.      (   Option1='P', Option2='R',Result=L1)
  15.     );
  16.     (  
  17.      (   Option1='S', Option2='R',Result=L2);
  18.      (   Option1='P', Option2='S',Result=L2);
  19.      (   Option1='R', Option2='P',Result=L2)
  20.     )).
  21. %game_winner([[X,'R'],[Y,'P']] , [Y,'P']). %var statica
  22.  
  23.  
  24. tournament([Tour1,Tour2],Result):-
  25.     tournament(Tour1,R1),
  26.     tournament(Tour2,R2),
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement