Beispiel #1
0
 // build a robot of a given type
 public static void buildRobot(RobotType type) throws GameActionException {
   if (rc.isCoreReady() && rc.hasBuildRequirements(type)) {
     Direction[] values = Direction.values();
     for (Direction dir : values) {
       if (rc.canBuild(dir, type)) {
         rc.build(dir, type);
         return;
       }
     }
   }
 }
Beispiel #2
0
 // build robots
 public static void buildRobots() throws GameActionException {
   // check if you should build
   if (rc.getTeamParts() > RobotType.TURRET.partCost) {
     // if the current type to build != null, build one of that type
     if (typeToBuild != null && rc.hasBuildRequirements(typeToBuild)) {
       buildRobot(typeToBuild);
       typeToBuild = null;
     } else {
       double percent = Math.random();
       if (percent <= Utility.PERCENTAGE_TURRETS) // build turret
       {
         typeToBuild = RobotType.TURRET;
       } else if (percent
           <= Utility.PERCENTAGE_TURRETS + Utility.PERCENTAGE_SOLDIERS) // build a soldier
       {
         typeToBuild = RobotType.SOLDIER;
       } else {
         typeToBuild = RobotType.SCOUT;
       }
     }
   }
 }