Exemple #1
0
  private void updateStrategicInfo() throws GameActionException {
    theirPastrs = rc.sensePastrLocations(them);
    numEnemyPastrs = theirPastrs.length;
    ourPastrs = rc.sensePastrLocations(us);
    numAlliedPastrs = ourPastrs.length;

    int numKillsLastTurn = MessageBoard.ROUND_KILL_COUNT.readInt();
    MessageBoard.ROUND_KILL_COUNT.writeInt(0);
    maxEnemySpawns -= numKillsLastTurn;

    virtualSpawnCountdown--;
    if (virtualSpawnCountdown <= 0) {
      maxEnemySpawns++;
      int maxEnemyPopCount = maxEnemySpawns + numEnemyPastrs;
      virtualSpawnCountdown =
          (int)
              Math.round(
                  GameConstants.HQ_SPAWN_DELAY_CONSTANT_1
                      + Math.pow(maxEnemyPopCount - 1, GameConstants.HQ_SPAWN_DELAY_CONSTANT_2));
    }
    maxEnemySoldiers = maxEnemySpawns - numEnemyPastrs;

    numAlliedSoldiers = 0;
    Robot[] allAlliedRobots = rc.senseNearbyGameObjects(Robot.class, 999999, us);
    allAllies = new RobotInfo[allAlliedRobots.length];
    for (int i = allAlliedRobots.length; i-- > 0; ) {
      RobotInfo info = rc.senseRobotInfo(allAlliedRobots[i]);
      allAllies[i] = info;
      if (info.type == RobotType.SOLDIER) numAlliedSoldiers++;
    }

    ourMilk = rc.senseTeamMilkQuantity(us);
    theirMilk = rc.senseTeamMilkQuantity(them);
  }
 private static void moveFromCorner(RobotController rc) throws GameActionException {
   int minRadius = 9; // units should try to maintain a minimum of 5 squared units
   // away from corner
   // @Hope - refine max radius
   int maxRadius = 26 + (int) Math.pow(rc.getRobotCount() / 6, 2); // based of number
   // of troops the max radius increases
   int distanceToCorner = rc.getLocation().distanceSquaredTo(turtleCorner);
   if (distanceToCorner <= minRadius && rc.isCoreReady()) {
     Direction dir = (rc.getLocation().directionTo(turtleCorner)).opposite();
     moveTowards(rc, dir);
   }
   if (distanceToCorner >= maxRadius && rc.isCoreReady()) {
     moveTowards(rc, rc.getLocation().directionTo(turtleCorner));
   }
 }
 /**
  * @param rc
  * @param dirToCorner
  * @return the location of the corner in the given direction or LOCATION_NONE if it is not a
  *     corner
  * @throws GameActionException
  */
 private static MapLocation checkForCorner(RobotController rc, Direction dirToCorner)
     throws GameActionException {
   int senseRadiusMinusOneSquared =
       (int) Math.pow(Math.sqrt(rc.getType().sensorRadiusSquared) - 1, 2);
   // so that when you add one below to check for a corner, you can still sense the +1 location
   MapLocation[] nearby =
       MapLocation.getAllMapLocationsWithinRadiusSq(rc.getLocation(), senseRadiusMinusOneSquared);
   boolean isCorner = true;
   MapLocation corner = getFurthestInDirection(rc, nearby, dirToCorner);
   Direction[] nearDirections = {dirToCorner, dirToCorner.rotateLeft(), dirToCorner.rotateRight()};
   for (Direction dir : nearDirections) {
     if (rc.onTheMap(corner.add(dir))) {
       isCorner = false;
     }
   }
   return isCorner ? corner : LOCATION_NONE;
 }
Exemple #4
0
 public static void generateProposals(
     MapLocation locus,
     int distToLocus,
     int incrementalDist,
     ArrayList<Proposal> proposalList,
     Direction[] consideredDirs) {
   for (Direction d : consideredDirs) {
     Proposal p;
     if (d.isDiagonal()) {
       p = new Proposal(locus.add(d), d, distToLocus + incrementalDist * 14);
     } else {
       p = new Proposal(locus.add(d), d, distToLocus + incrementalDist * 10);
     }
     int val = BreadthFirst.getMapData(p.loc);
     if (val > 0) { // not off-map or entirely void-filled
       p.dist +=
           Math.pow((val - 10000), 2)
               * 10; // TODO evaluate fudge factor of 10 for importance of void spaces
       proposalList.add(p);
     }
   }
 }