Advertisement
Guest User

Untitled

a guest
Dec 16th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. package bots;
  2. import penguin_game.*;
  3.  
  4. public class MyBot implements SkillzBot {
  5. static int turns = 0;
  6. @Override
  7. public void doTurn(Game game) {
  8. // Go over all of my icebergs.
  9.  
  10. for (Iceberg myIceberg : game.getMyIcebergs())
  11. {
  12. // The amount of penguins in my iceberg.
  13. Iceberg maybe1 = null;
  14. Iceberg maybe2 = null;
  15. int myPenguinAmount = myIceberg.penguinAmount;
  16. Iceberg destination = null;
  17. Iceberg choseOne;
  18. Iceberg toUp;
  19. Iceberg[] maybe = game.getNeutralIcebergs();
  20. if (maybe.length > 0){
  21. choseOne = maybe[0];
  22. int index = -1;
  23. int prev = 100;
  24. Iceberg base = game.getMyIcebergs()[0];
  25. for(int i = 1; i < maybe.length; i++)
  26. {
  27. prev = Math.min(base.getTurnsTillArrival(choseOne), prev);
  28. if (prev == base.getTurnsTillArrival(choseOne))
  29. {
  30. index = i;
  31. }
  32. choseOne = maybe[i];
  33. System.out.println(index);
  34.  
  35. }
  36. maybe1 = choseOne;
  37. }
  38. maybe = game.getEnemyIcebergs();
  39. if(maybe.length > 0)
  40. {
  41. choseOne = maybe[0];
  42. int index = -1;
  43. int prev = 100;
  44. Iceberg base = game.getMyIcebergs()[0];
  45. for(int i = 1; i < maybe.length; i++)
  46. {
  47. prev = Math.min(base.getTurnsTillArrival(choseOne), prev);
  48. if (prev == base.getTurnsTillArrival(choseOne))
  49. {
  50. index = i;
  51. }
  52. choseOne = maybe[i];
  53. }
  54. maybe2 = choseOne;
  55. }
  56.  
  57. if(turns % 2 == 0 && maybe1 != null)
  58. {
  59. destination = maybe1;
  60. turns++;
  61. }
  62. else
  63. {
  64. destination = maybe2;
  65. turns++;
  66. }
  67. Iceberg[] myice = game.getMyIcebergs();
  68.  
  69.  
  70. // The amount of penguins the target has.
  71. int destinationPenguinAmount = destination.penguinAmount;
  72. // If my iceberg has more penguins than the target iceberg.
  73. if (myPenguinAmount > destinationPenguinAmount) {
  74. // Send penguins to the target.
  75. System.out.println(myIceberg + " sends "+ (destinationPenguinAmount + 1) + " penguins to "+ destination);
  76. myIceberg.sendPenguins(destination, destinationPenguinAmount + 1);
  77. }
  78. }
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement