Advertisement
Guest User

Untitled

a guest
Nov 25th, 2015
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. int worstValue = 12;
  2. int worstCard = -1;
  3. int[] suitAmount = new int[4];
  4. int suitMax = 0;
  5. int max = 0;
  6.  
  7. for (int i = 0; i < 4; i++)
  8. {
  9. suitAmount[game.suitToInt(hand[i].suit)]++;
  10. }
  11. for (int i = 0; i < 4; i++)
  12. {
  13. if (suitAmount[i] > suitMax)
  14. {
  15. suitMax = suitAmount[i];
  16. max = i;
  17. }
  18. }
  19.  
  20.  
  21.  
  22.  
  23.  
  24. if (suitAmount[max] > 1 && game.suitScore(hand, game.intToSuit(max)) > 15)
  25. {
  26. if (suitAmount[max] > 3)
  27. {
  28. for (int i = 0; i < 4; i++)
  29. {
  30. if (hand[i].value < worstValue)
  31. {
  32. worstValue = hand[i].value;
  33. worstCard = i;
  34. }
  35.  
  36. }
  37. return worstCard;
  38. }
  39. else
  40. {
  41. for (int i = 0; i < 4; i++)
  42. {
  43. if (hand[i].value < worstValue && hand[i].suit != game.intToSuit(max))
  44. {
  45. worstValue = hand[i].value;
  46. worstCard = i;
  47. }
  48.  
  49. }
  50. return worstCard;
  51.  
  52. }
  53. }
  54. else
  55. {
  56. for (int i = 0; i < 4; i++)
  57. {
  58. if (hand[i].value < worstValue) //Tittar igenom handen efter det lägsta kortet och kastar det
  59. {
  60. worstValue = hand[i].value;
  61. worstCard = i;
  62. }
  63. }
  64. return worstCard;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement