Advertisement
teleias

Team Generator

Dec 29th, 2014
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 2.17 KB | None | 0 0
  1. %team generator
  2.  
  3. entrant(e_Isunari,59).
  4. entrant(e_a5vAstra,51).
  5. entrant(e_JXM,55).
  6. entrant(e_neoprotector,45).
  7. entrant(e_Rasengan,43).
  8. entrant(e_LittleChook,41).
  9. entrant(e_WorstLeonaNA,41).
  10. entrant(e_Cloudspire,35).
  11. entrant(e_kansasguy,33).
  12. entrant(e_Jupper,33).
  13. entrant(e_Tagster,33).
  14. entrant(e_Windstance,33).
  15. entrant(e_Storyteller1011,27).
  16. entrant(e_kingofthewalrus,27).
  17. entrant(e_TurtleSayuri,23).
  18. entrant(e_Praetors,19).
  19. entrant(e_Snowmelt,39).
  20. entrant(e_Shaunbiezel,37).
  21. entrant(e_Riceball13,41).
  22.  
  23. point(Entrant,A) :- entrant(Entrant,A).
  24. pointTotal([],0).
  25. pointTotal([Ta|Tb],A) :- point(Ta,A2), pointTotal(Tb,A3), A is A2+A3.
  26.  
  27. makeTeam(List, Team1, Team2) :- makeTeam(List, Team1, Team2, Pt1, Pt2, Ptd).
  28. makeTeam(List, Team1, Team2, Pt1, Pt2, Ptd) :- pick5(List, Team1), pick5(List, Team2), distinctLists(Team1, Team2), pointTotal(Team1, Pt1), pointTotal(Team2, Pt2), Ptd is Pt1-Pt2, absValLessThanX(Ptd,2).
  29. makeTeam(List, Team1, Team2, Pt1, Pt2, Ptd) :- pick5(List, Team1), pick5(List, Team2), distinctLists(Team1, Team2), pointTotal(Team1, Pt1), pointTotal(Team2, Pt2), Ptd is Pt1-Pt2, absValLessThanX(Ptd,2).
  30. absValLessThanX(P,X) :- P >= -1*X, P =< X.
  31. distinctLists([],_).
  32. distinctLists([T1a|T1b],T2) :- distinct(T2, T1a), distinctLists(T1b,T2).
  33. noDuplicates([],1).
  34. noDuplicates([La|Lb],A) :- distinct(Lb,La), !, noDuplicates(Lb,A).
  35. noDuplicates([La|Lb],0).
  36. %       remove all of L1 from L2
  37. removeListFromList([],A,A).
  38. removeListFromList([L1a|L1b],L2,A) :- removeFromList(L2,L1a,NL2), removeListFromList(L1b,NL2,A).
  39. removeFromList([La],_,[La]).
  40. removeFromList([X|Lb],X,A) :- !, removeFromList(Lb,X,A).
  41. removeFromList([La|Lb],X,[La|A]) :- removeFromList(Lb,X,A).
  42. distinct([],_).
  43. distinct([La|Lb],La) :- fail.
  44. distinct([La|Lb],X) :- X \= La, distinct(Lb,X).
  45. %pick5(L,[P1,P2,P3,P4]) :- pick(L,P1), pick(L,P2), pick(L,P3), pick(L,P4), noDuplicates([P1,P2,P3,P4], NoDups), NoDups \= 0.
  46. pick5(L,[P1,P2,P3,P4,P5]) :- pick(L,P1), pick(L,P2), pick(L,P3), pick(L,P4), pick(L,P5), noDuplicates([P1,P2,P3,P4,P5], NoDups), NoDups \= 0.
  47. pick([],_) :- fail.
  48. pick([La|Lb],La).
  49. pick([La|Lb],P) :- pick(Lb,P).
  50.  
  51.  
  52. count([], A) :- A is 0.
  53. count([_|L1b], A) :- count(L1b, A2), A is A2+1.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement