Skip to main content
added 26 characters in body
Source Link
Xynariz
  • 338
  • 1
  • 7

The Guardian will pick on the same player repeatedly if needed. Ties for "weakest player" and "who picked on him" both go to the first one in the list (which is to say, random).

The Guardian will pick on the same player repeatedly if needed. Ties for "weakest player" and "who picked on him" both go to the first one in the list.

The Guardian will pick on the same player repeatedly if needed. Ties for "weakest player" and "who picked on him" both go to the first one in the list (which is to say, random).

Fixed typos
Source Link
Xynariz
  • 338
  • 1
  • 7
public class Guardian{
    public static void main (String[] args){
        if(args.length == 0){
            System.out.print("ok");
            System.exit(0);
        }

        String myId = args[0];
        int lowestLife = Integer.MAX_VALUE;
        int life = Integer.MIN_VALUE;
        String[] tokens = {};
        String opposingId = "";
        String weakestOpponent = "";
        String lastTarget = "";

        for(int i=1; i<args.length; i++){
            tokens = args[i].split(",");
            otherIdopposingId = tokens[0];
            life = Integer.ValueOfparseInt(tokens[1]);
            lastTarget = tokens[3];
            if(life < lowestLife && life > 0 &&
                !otheropposingId.equals(myId) &&
                !otheropposingId.equals(lastTarget)){
                weakestOpponent = otherId;opposingId;
            }
        }

        for(int i=1; i<args.length; i++){
            tokens = args[i].split(",");
            otherIdopposingId = tokens[0];
            life = Integer.ValueOfparseInt(tokens[1]);
            lastTarget = tokens[3];
            if (lastTarget.equals(weakestOpponent) &&
                life > 10){
                System.out.println(otherIdopposingId);
                System.exit(0);
            }
        }

        SytemSystem.out.println("D");
    }
}
public class Guardian{
    public static void main (String[] args){
        if(args.length == 0){
            System.out.print("ok");
            System.exit(0);
        }

        String myId = args[0];
        int lowestLife = Integer.MAX_VALUE;
        String[] tokens = {};
        String opposingId = "";
        String weakestOpponent = "";
        String lastTarget = "";

        for(int i=1; i<args.length; i++){
            tokens = args[i].split(",");
            otherId = tokens[0];
            life = Integer.ValueOf(tokens[1]);
            lastTarget = tokens[3];
            if(life < lowestLife && life > 0 &&
                !other.equals(myId) &&
                !other.equals(lastTarget)){
                weakestOpponent = otherId;
            }
        }

        for(int i=1; i<args.length; i++){
            tokens = args[i].split(",");
            otherId = tokens[0];
            life = Integer.ValueOf(tokens[1]);
            lastTarget = tokens[3];
            if (lastTarget.equals(weakestOpponent) &&
                life > 10){
                System.out.println(otherId);
                System.exit(0);
            }
        }

        Sytem.out.println("D");
    }
}
public class Guardian{
    public static void main (String[] args){
        if(args.length == 0){
            System.out.print("ok");
            System.exit(0);
        }

        String myId = args[0];
        int lowestLife = Integer.MAX_VALUE;
        int life = Integer.MIN_VALUE;
        String[] tokens = {};
        String opposingId = "";
        String weakestOpponent = "";
        String lastTarget = "";

        for(int i=1; i<args.length; i++){
            tokens = args[i].split(",");
            opposingId = tokens[0];
            life = Integer.parseInt(tokens[1]);
            lastTarget = tokens[3];
            if(life < lowestLife && life > 0 &&
                !opposingId.equals(myId) &&
                !opposingId.equals(lastTarget)){
                weakestOpponent = opposingId;
            }
        }

        for(int i=1; i<args.length; i++){
            tokens = args[i].split(",");
            opposingId = tokens[0];
            life = Integer.parseInt(tokens[1]);
            lastTarget = tokens[3];
            if (lastTarget.equals(weakestOpponent) &&
                life > 10){
                System.out.println(opposingId);
                System.exit(0);
            }
        }

        System.out.println("D");
    }
}
Source Link
Xynariz
  • 338
  • 1
  • 7

Java Guardian

The Guardian protects the weak. He will attack whoever spent their last turn picking on the now-weakest living bot (besides possibly himself). He's smart enough, though, to not attack:

  1. Himself (unless he is the bully, then he feels that he deserves it.)

  2. Bots who attack themselves

  3. Dead bots

  4. Bots with less than ten life left (who have hopefully learned their lessons!)

The Guardian will pick on the same player repeatedly if needed. Ties for "weakest player" and "who picked on him" both go to the first one in the list.

public class Guardian{
    public static void main (String[] args){
        if(args.length == 0){
            System.out.print("ok");
            System.exit(0);
        }

        String myId = args[0];
        int lowestLife = Integer.MAX_VALUE;
        String[] tokens = {};
        String opposingId = "";
        String weakestOpponent = "";
        String lastTarget = "";

        for(int i=1; i<args.length; i++){
            tokens = args[i].split(",");
            otherId = tokens[0];
            life = Integer.ValueOf(tokens[1]);
            lastTarget = tokens[3];
            if(life < lowestLife && life > 0 &&
                !other.equals(myId) &&
                !other.equals(lastTarget)){
                weakestOpponent = otherId;
            }
        }

        for(int i=1; i<args.length; i++){
            tokens = args[i].split(",");
            otherId = tokens[0];
            life = Integer.ValueOf(tokens[1]);
            lastTarget = tokens[3];
            if (lastTarget.equals(weakestOpponent) &&
                life > 10){
                System.out.println(otherId);
                System.exit(0);
            }
        }

        Sytem.out.println("D");
    }
}