private static void goToLocation(MapLocation whereToGo) throws GameActionException {

    //		if (rc.isActive()) {
    //			if(encampmentLocationArray == null){ // find encampments
    //				encampmentLocationArray = rc.senseAllEncampmentSquares();
    //			}
    //			if (counter < 10 && rc.senseMine(rc.getLocation()) == null) { // lay mines behind robots
    //				if(rc.senseMine(rc.getLocation())==null)
    //					rc.layMine();

    // Send all robots to the passed in argument.
    int dist = rc.getLocation().distanceSquaredTo(whereToGo);
    if (dist > 0) { // dist > 0 && rc.isActive()
      Direction dir = rc.getLocation().directionTo(whereToGo);
      Direction curDir = dir;

      int[] directionOffSets = {0, 1, -1, 2, -2};

      lookForDir:
      for (int d : directionOffSets) {
        curDir = Direction.values()[(dir.ordinal() + d + 8) % 8];
        if (rc.canMove(curDir)) {
          break lookForDir;
        }
      }
      Team mine = rc.senseMine(rc.getLocation().add(curDir));
      if (mine != null && mine != rc.getTeam()) {
        rc.defuseMine(rc.getLocation().add(curDir));
      } else {
        rc.move(curDir);
        rc.setIndicatorString(0, "Last direction moved: " + dir.toString());
      }
    }
  }
示例#2
0
 public static void rangedDefuseMine() throws GameActionException {
   if (rc.hasUpgrade(Upgrade.DEFUSION)) {
     MapLocation[] mines = rc.senseMineLocations(rc.getLocation(), 14, rc.getTeam().opponent());
     if (mines.length > 0 && rc.isActive()) {
       rc.defuseMine(mines[0]);
     }
   }
 }
示例#3
0
 private static void moveOrDefuse(Direction dir) throws GameActionException {
   MapLocation ahead = rc.getLocation().add(dir);
   if (rc.senseMine(ahead) != null) {
     rc.defuseMine(ahead);
   } else {
     rc.move(dir);
   }
 }
 private void moveOrDefuse(Direction dir) throws GameActionException {
   MapLocation ahead = rc.getLocation().add(dir);
   if (rc.canMove(dir) && rc.senseMine(ahead) != null && rc.senseMine(ahead) != rc.getTeam()) {
     rc.defuseMine(ahead);
   } else {
     if (rc.canMove(dir)) {
       rc.move(dir);
     }
   }
 }
示例#5
0
 public static boolean moveOrDefuse(Direction dir) throws GameActionException {
   if (rc.isActive()) {
     if (rc.canMove(dir)) {
       if (!hasBadMine(rc.getLocation().add(dir))) {
         rc.move(dir);
         return true;
       } else {
         rc.defuseMine(rc.getLocation().add(dir));
         return false;
       }
     }
     return false;
   }
   return false;
 }
 public void evalMove(MapLocation currentLocation, MapLocation whereToGo)
     throws GameActionException { // New pathing algorithm
   // SHOULD WE CONSIDER NOT MOVING??
   if (rc.isActive()) {
     try {
       this.mapIntDistribution[currentLocation.x][currentLocation.y] += 1;
     } catch (Exception e) {
       this.mapIntDistribution[currentLocation.x][currentLocation.y] = 1;
     }
     int[] dirOffsets = {0, 1, 2, 3, 4, 5, 6, 7};
     int bestScore = -1;
     Direction bestDir = null;
     for (int offset : dirOffsets) {
       Direction dir = Direction.values()[offset];
       if (rc.canMove(dir)) {
         int score =
             this.evalDirection(
                 currentLocation,
                 dir,
                 whereToGo,
                 currentLocation.directionTo(whereToGo),
                 this.movesAway(currentLocation, whereToGo));
         if (bestDir == null) {
           bestScore = score;
           bestDir = dir;
         } else if (score < bestScore) {
           bestScore = score;
           bestDir = dir;
         }
       }
     }
     if (bestDir != null) {
       rc.setIndicatorString(
           0,
           "Best score: "
               + bestScore
               + ", Direction to target: "
               + currentLocation.directionTo(whereToGo));
       MapLocation moveSquare = currentLocation.add(bestDir);
       if (this.mineHazard(moveSquare)) {
         rc.defuseMine(moveSquare);
       } else {
         rc.move(bestDir);
       }
     }
   }
 }
 private static void goDirectionAndDefuse(Direction dir) throws GameActionException {
   int[] directionOffsets = {0, 1, -1, 2, -2};
   Direction lookingAtCurrently = dir;
   lookAround:
   for (int d : directionOffsets) {
     lookingAtCurrently = Direction.values()[(dir.ordinal() + d + 8) % 8];
     if (rc.canMove(lookingAtCurrently)) {
       if (badBomb(rc.getLocation().add(lookingAtCurrently))) {
         rc.defuseMine(rc.getLocation().add(lookingAtCurrently));
       } else {
         rc.move(lookingAtCurrently);
         rc.setIndicatorString(0, "Last direction moved: " + lookingAtCurrently.toString());
       }
       break lookAround;
     }
   }
 }
示例#8
0
 public static void goDirectionAndDefuse(Direction dir) throws GameActionException {
   if (rc.isActive()) {
     Direction lookingAtCurrently = dir;
     lookAround:
     for (int d : directionOffsets) {
       lookingAtCurrently = Direction.values()[(dir.ordinal() + d + 8) % 8];
       if (rc.isActive() && rc.canMove(lookingAtCurrently)) {
         if (hasBadMine(rc.getLocation().add(lookingAtCurrently))) {
           rc.defuseMine(rc.getLocation().add(lookingAtCurrently));
         } else {
           rc.move(lookingAtCurrently);
         }
         break lookAround;
       }
     }
   }
 }