Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package bots;
- import penguin_game.*;
- public class MyBot implements SkillzBot {
- static int turns = 0;
- @Override
- public void doTurn(Game game) {
- // Go over all of my icebergs.
- for (Iceberg myIceberg : game.getMyIcebergs())
- {
- // The amount of penguins in my iceberg.
- Iceberg maybe1 = null;
- Iceberg maybe2 = null;
- int myPenguinAmount = myIceberg.penguinAmount;
- Iceberg destination = null;
- Iceberg choseOne;
- Iceberg toUp;
- Iceberg[] maybe = game.getNeutralIcebergs();
- if (maybe.length > 0){
- choseOne = maybe[0];
- int index = -1;
- int prev = 100;
- Iceberg base = game.getMyIcebergs()[0];
- for(int i = 1; i < maybe.length; i++)
- {
- prev = Math.min(base.getTurnsTillArrival(choseOne), prev);
- if (prev == base.getTurnsTillArrival(choseOne))
- {
- index = i;
- }
- choseOne = maybe[i];
- System.out.println(index);
- }
- maybe1 = choseOne;
- }
- maybe = game.getEnemyIcebergs();
- if(maybe.length > 0)
- {
- choseOne = maybe[0];
- int index = -1;
- int prev = 100;
- Iceberg base = game.getMyIcebergs()[0];
- for(int i = 1; i < maybe.length; i++)
- {
- prev = Math.min(base.getTurnsTillArrival(choseOne), prev);
- if (prev == base.getTurnsTillArrival(choseOne))
- {
- index = i;
- }
- choseOne = maybe[i];
- }
- maybe2 = choseOne;
- }
- if(turns % 2 == 0 && maybe1 != null)
- {
- destination = maybe1;
- turns++;
- }
- else
- {
- destination = maybe2;
- turns++;
- }
- Iceberg[] myice = game.getMyIcebergs();
- // The amount of penguins the target has.
- int destinationPenguinAmount = destination.penguinAmount;
- // If my iceberg has more penguins than the target iceberg.
- if (myPenguinAmount > destinationPenguinAmount) {
- // Send penguins to the target.
- System.out.println(myIceberg + " sends "+ (destinationPenguinAmount + 1) + " penguins to "+ destination);
- myIceberg.sendPenguins(destination, destinationPenguinAmount + 1);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement