예제 #1
0
 ///////////////////////////////////////////////////////////
 // closestArchonLoc()
 //
 private static MapLocation closestArchonLoc() {
   RobotInfo[] ri = rc.senseNearbyRobots(rc.getLocation(), 15, myTeam);
   MapLocation loc = rc.getLocation();
   int i = 0;
   int dist = 0;
   int closest = 99;
   while (i < ri.length) {
     if (ri[i].type == RobotType.ARCHON) {
       closest = i;
       break;
     }
     i++;
   }
   if (closest == 99) {
     return null;
   }
   // found 1
   dist = rc.getLocation().distanceSquaredTo(ri[closest].location);
   int newDist;
   for (i = i + 1; i < ri.length; i++) {
     if (ri[i].type == RobotType.ARCHON) {
       newDist = loc.distanceSquaredTo(ri[i].location);
       if (newDist < dist) {
         dist = newDist;
         closest = i;
       }
     }
   }
   return ri[closest].location;
 }
예제 #2
0
 /////////////////////////////////////////////////////////////
 // moveAway()
 //
 private static boolean moveAway(MapLocation center) throws GameActionException {
   while (!rc.isCoreReady()) {
     Clock.yield();
   }
   Direction dir = center.directionTo(rc.getLocation());
   int c = 0;
   while (!rc.canMove(dir)) {
     dir = dir.rotateRight();
     c++;
     if (c >= 4) return false;
   }
   rc.move(dir);
   return true;
 }