Beispiel #1
0
  /**
   * Archon checks within a squared radius of 9 for neutral units. If neutral archon, always head
   * toward and activate. If no neutral archons are detected, activate adjacent units. If no
   * adjacent units, move towards nearest neutral unit.
   *
   * @param rc must be archon
   * @return if activated a unit
   * @throws GameActionException
   */
  private static void activateUnits(RobotController rc) throws GameActionException {

    if (rc.isCoreReady()) activateFirst(rc);
    int lowestDistanceIndex = 0;
    MapLocation myLocation = rc.getLocation();
    MapLocation robotLocation;
    RobotInfo[] robots = rc.senseNearbyRobots(ACTIVATION_RADIUS_SQUARED, Team.NEUTRAL);
    for (int i = 0; i < robots.length; i++) {
      robotLocation = robots[i].location;
      if (rc.isCoreReady() && robots[i].type == RobotType.ARCHON) {
        if (myLocation.isAdjacentTo(robotLocation)) {
          rc.activate(robotLocation);
        } else {
          moveTowards(rc, myLocation.directionTo(robotLocation));
        }
      }
      if (robots[i].type != RobotType.ARCHON) {
        lowestDistanceIndex =
            myLocation.distanceSquaredTo(robotLocation)
                    < myLocation.distanceSquaredTo(robots[lowestDistanceIndex].location)
                ? i
                : lowestDistanceIndex;
      }
    }
    if (rc.isCoreReady() && robots.length > 0) {
      if (myLocation.isAdjacentTo(robots[lowestDistanceIndex].location)) {
        rc.activate(robots[lowestDistanceIndex].location);
      } else {
        moveTowards(rc, myLocation.directionTo(robots[lowestDistanceIndex].location));
      }
    }
  }
Beispiel #2
0
 static void activateCommon(RobotController rc, MapLocation loc) throws GameActionException {
   rc.activate(loc);
   lastBuiltLocation = loc;
   RobotInfo info = rc.senseRobotAtLocation(lastBuiltLocation);
   addInfo(info);
   lastBuiltId = info.ID;
 }
Beispiel #3
0
 /**
  * Repairs the first-sensed neutral robot, if rc's core is ready
  *
  * @param rc must be an archon
  * @throws GameActionException
  */
 private static boolean activateFirst(RobotController rc) throws GameActionException {
   boolean hasActed = false;
   RobotInfo[] nearbyNeutralRobots = rc.senseNearbyRobots(ONE_SQUARE_RADIUS, Team.NEUTRAL);
   if (nearbyNeutralRobots.length > 0) {
     rc.activate(nearbyNeutralRobots[0].location);
     hasActed = true;
   }
   return hasActed;
 }