Advertisement
Guest User

Untitled

a guest
Nov 17th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. baralho(L2) :- ranks(L1), allcards(L1,_,L), random_permutation(L,L2), distribui([_,_],L2,_).
  2.  
  3. %lista de todas as cartas(produto cartesiano das listas ranks e naipe)
  4. allcards([],_,_).
  5. allcards([X|L1],L2,R) :- naipe(L2), aux_cards(X,L2,L3),
  6. allcards(L1,L2,L4), append(L3,L4,R).
  7. aux_cards(_,[],[]).
  8. aux_cards(X,[Y|L1],[(X,Y)|L2]) :-aux_cards(X,L1,L2).
  9.  
  10.  
  11. %mesa().
  12. %numero de cartas por jogador = 7
  13. distribui([P1,P2],L,L3):- aux_distribui(P1,L,L2), aux_distribui(P2,L2,L3).
  14.  
  15. aux_distribui(P,[X,Y,Z|_],L2) :- hand(P,[X,Y,Z]), delete([X,Y,Z],[X,Y,Z|L2],L2).
  16.  
  17.  
  18. hand(_,[X,Y,Z|_]):- baralho([X,Y,Z|_]).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement