private static void removeTurretLocations(RobotController rc) throws GameActionException {
   MapLocation[] removedLocations = new MapLocation[turretLocations.size()];
   int removedLength = 0;
   for (MapLocation location : turretLocations) {
     if (rc.canSenseLocation(location)) {
       RobotInfo info = rc.senseRobotAtLocation(location);
       if (info == null) {
         removedLocations[removedLength++] = location;
       } else if (info.team != enemyTeam
           || (info.team == enemyTeam && info.type != RobotType.TURRET)) {
         removedLocations[removedLength++] = location;
       }
     }
   }
   for (int i = 0; i < removedLength; i++) {
     turretLocations.remove(removedLocations[i]);
   }
 }
  private static void rushMicro(RobotController rc, RobotInfo[] hostiles)
      throws GameActionException {
    // Prioritizes attacking turrets.
    RobotInfo bestEnemy = null;
    boolean canAttackBestEnemy = false;
    int bestEnemyDist = 10000; // only care if can't hit
    for (RobotInfo hostile : hostiles) {
      // Can attack this enemy.
      int dist = myLoc.distanceSquaredTo(hostile.location);
      // Summary:
      // Prioritizes enemies over zombies.
      // Prioritizes turret enemies over other enemies.
      // Prioritizes lowest health enemy last
      if (dist <= attackRadius) {
        if (bestEnemy != null) {
          if (bestEnemy.team == enemyTeam) { // best is already enemy
            if (hostile.team == enemyTeam) { // found an enemy
              if (countsAsTurret(bestEnemy.type)) {
                if (countsAsTurret(hostile.type)) {
                  // Take lowest health
                  if (bestEnemy.health > hostile.health) bestEnemy = hostile;
                }
              } else {
                if (countsAsTurret(hostile.type)) {
                  bestEnemy = hostile;
                } else {
                  // Take lowest health
                  if (bestEnemy.health > hostile.health) bestEnemy = hostile;
                }
              }
            }
          } else { // best is not an enemy!
            if (hostile.team == enemyTeam) { // found an enemy
              bestEnemy = hostile;
            } else {
              // Take lowest health
              if (bestEnemy.health > hostile.health) bestEnemy = hostile;
            }
          }
        } else {
          bestEnemy = hostile;
        }
        canAttackBestEnemy = true;
      } else {
        // Only update best enemy if you can't attack best enemy
        if (!canAttackBestEnemy) {
          if (bestEnemy != null) {
            // Pick the closest one
            if (bestEnemyDist > dist) {
              bestEnemyDist = dist;
              bestEnemy = hostile;
            }
          } else {
            bestEnemyDist = dist;
            bestEnemy = hostile;
          }
        }
      }
    }
    rc.setIndicatorString(0, "Round: " + rc.getRoundNum() + ", Best enemy: " + bestEnemy);
    if (rc.isCoreReady()) {
      // If there is a best enemy, attack him.
      if (bestEnemy != null) {
        // Move closer only if blocking someone.
        if (rc.canAttackLocation(bestEnemy.location)) {
          if (isBlockingSomeone(rc, bestEnemy.location)) {
            Direction desired = myLoc.directionTo(bestEnemy.location);
            Direction dir = Movement.getBestMoveableDirection(desired, rc, 2);
            if (dir != Direction.NONE) {
              rc.move(dir);
            } else if (shouldMine(rc, desired)) {
              rc.clearRubble(desired);
            } else if (shouldMine(rc, desired.rotateLeft())) {
              rc.clearRubble(desired.rotateLeft());
            } else if (shouldMine(rc, desired.rotateRight())) {
              rc.clearRubble(desired.rotateRight());
            }
          }
        }
        // If can't attack it, move closer!
        else {
          Direction desired = myLoc.directionTo(bestEnemy.location);
          Direction dir = Movement.getBestMoveableDirection(desired, rc, 2);
          if (dir != Direction.NONE) {
            rc.move(dir);
          } else if (shouldMine(rc, desired)) {
            rc.clearRubble(desired);
          } else if (shouldMine(rc, desired.rotateLeft())) {
            rc.clearRubble(dir.rotateLeft());
          } else if (shouldMine(rc, desired.rotateRight())) {
            rc.clearRubble(desired.rotateRight());
          }
        }
      }
      // Otherwise move closer to destination
      else {
        if (currentDestination != null) {
          RobotInfo info = null;
          if (rc.canSenseLocation(currentDestination)) {
            info = rc.senseRobotAtLocation(currentDestination);
          }
          if (info != null) {
            // If can attack it, just only move closer if blocking someone behind.
            if (rc.canAttackLocation(info.location)) {
              if (isBlockingSomeone(rc, currentDestination)) {
                Direction desired = myLoc.directionTo(currentDestination);
                Direction dir = Movement.getBestMoveableDirection(desired, rc, 2);
                if (dir != Direction.NONE) {
                  rc.move(dir);
                } else if (shouldMine(rc, desired)) {
                  rc.clearRubble(desired);
                } else if (shouldMine(rc, desired.rotateLeft())) {
                  rc.clearRubble(desired.rotateLeft());
                } else if (shouldMine(rc, desired.rotateRight())) {
                  rc.clearRubble(desired.rotateRight());
                }
              }
            }
            // If can't attack it, move closer!
            else {
              Direction desired = myLoc.directionTo(currentDestination);
              Direction dir = Movement.getBestMoveableDirection(desired, rc, 2);
              if (dir != Direction.NONE) {
                rc.move(dir);
              } else if (shouldMine(rc, desired)) {
                rc.clearRubble(desired);
              } else if (shouldMine(rc, desired.rotateLeft())) {
                rc.clearRubble(desired.rotateLeft());
              } else if (shouldMine(rc, desired.rotateRight())) {
                rc.clearRubble(desired.rotateRight());
              }
            }
          }
          // If not there, just move closer.
          else {
            Direction desired = myLoc.directionTo(currentDestination);
            Direction dir = Movement.getBestMoveableDirection(desired, rc, 2);
            if (dir != Direction.NONE) {
              rc.move(dir);
            } else if (shouldMine(rc, desired)) {
              rc.clearRubble(desired);
            } else if (shouldMine(rc, desired.rotateLeft())) {
              rc.clearRubble(desired.rotateLeft());
            } else if (shouldMine(rc, desired.rotateRight())) {
              rc.clearRubble(desired.rotateRight());
            }
          }
        }
      }
    }

    // Attack whenever you can.
    if (bestEnemy != null) {
      if (rc.isWeaponReady()) {
        if (rc.canAttackLocation(bestEnemy.location)) {
          broadcastingAttack(rc, bestEnemy);
        }
      }
    }
  }