Exemplo n.º 1
0
 // if soldier is in range of stuff but doesn't see it, sets it to null
 public static void resetLocations(RobotController rc) throws GameActionException {
   if (nearestTurretLocation != null
       && myLoc.distanceSquaredTo(nearestTurretLocation) <= 13
       && (rc.senseRobotAtLocation(nearestTurretLocation) == null
           || rc.senseRobotAtLocation(nearestTurretLocation).type != RobotType.TURRET
           || !rc.senseRobotAtLocation(nearestTurretLocation).team.equals(enemyTeam))) {
     if (nearestTurretLocation.equals(currentDestination)) currentDestination = null;
     nearestTurretLocation = null;
   }
   if (nearestEnemyLocation != null
       && myLoc.distanceSquaredTo(nearestEnemyLocation) <= 13
       && (rc.senseRobotAtLocation(nearestEnemyLocation) == null
           || !rc.senseRobotAtLocation(nearestEnemyLocation).team.equals(enemyTeam))) {
     if (nearestEnemyLocation.equals(currentDestination)) currentDestination = null;
     nearestEnemyLocation = null;
   }
   if (nearestDenLocation != null
       && rc.canSense(nearestDenLocation)
       && (rc.senseRobotAtLocation(nearestDenLocation) == null
           || rc.senseRobotAtLocation(nearestDenLocation).type != RobotType.ZOMBIEDEN)) {
     if (nearestDenLocation.equals(currentDestination)) currentDestination = null;
     nearestDenLocation = null;
   }
   if (nearestDistressedArchon != null
           && myLoc.distanceSquaredTo(nearestDistressedArchon) <= 13
           && (rc.senseRobotAtLocation(nearestDistressedArchon) == null
               || !rc.senseRobotAtLocation(nearestDistressedArchon).team.equals(enemyTeam))
       || distressedArchonTurns > 5) {
     if (nearestDistressedArchon != null && nearestDistressedArchon.equals(currentDestination))
       currentDestination = null;
     nearestDistressedArchon = null;
     distressedArchonTurns = 0;
   }
 }
Exemplo n.º 2
0
 /**
  * Expensive method. Should call upon initialization only.
  *
  * @param rc
  * @throws GameActionException
  */
 static void senseRubble(RobotController rc) throws GameActionException {
   int roundNum = rc.getRoundNum();
   for (int x = -straightSight; x <= straightSight; ++x) {
     for (int y = -straightSight; y <= straightSight; ++y) {
       MapLocation loc = rc.getLocation().add(x, y);
       if (rc.canSense(loc)) {
         rubbleTimes[loc.x % MAP_MOD][loc.y % MAP_MOD] = roundNum;
         mapRubble[loc.x % MAP_MOD][loc.y % MAP_MOD] = rc.senseRubble(loc);
       }
     }
   }
 }
Exemplo n.º 3
0
 /**
  * Move and update history
  *
  * @param rc
  * @param dir
  */
 static void move(RobotController rc, Direction dir) throws GameActionException {
   rc.move(dir);
   MapLocation loc = rc.getLocation();
   history[historySize++] = loc;
   int roundNum = rc.getRoundNum();
   switch (dir) {
     case NORTH_EAST:
     case EAST:
     case SOUTH_EAST:
       for (int y = -straightSight; y <= straightSight; ++y) {
         MapLocation senseLocation = loc.add(straightSight, y);
         if (rc.canSense(senseLocation)) {
           rubbleTimes[senseLocation.x % MAP_MOD][senseLocation.y % MAP_MOD] = roundNum;
           mapRubble[senseLocation.x % MAP_MOD][senseLocation.y % MAP_MOD] =
               rc.senseRubble(senseLocation);
         }
       }
       break;
     case SOUTH_WEST:
     case WEST:
     case NORTH_WEST:
       for (int y = -straightSight; y <= straightSight; ++y) {
         MapLocation senseLocation = loc.add(-straightSight, y);
         if (rc.canSense(senseLocation)) {
           rubbleTimes[senseLocation.x % MAP_MOD][senseLocation.y % MAP_MOD] = roundNum;
           mapRubble[senseLocation.x % MAP_MOD][senseLocation.y % MAP_MOD] =
               rc.senseRubble(senseLocation);
         }
       }
       break;
     default:
       break;
   }
   switch (dir) {
     case NORTH_WEST:
     case NORTH:
     case NORTH_EAST:
       for (int x = -straightSight; x <= straightSight; ++x) {
         MapLocation senseLocation = loc.add(x, straightSight);
         if (rc.canSense(senseLocation)) {
           rubbleTimes[senseLocation.x % MAP_MOD][senseLocation.y % MAP_MOD] = roundNum;
           mapRubble[senseLocation.x % MAP_MOD][senseLocation.y % MAP_MOD] =
               rc.senseRubble(senseLocation);
         }
       }
       break;
     case SOUTH_EAST:
     case SOUTH:
     case SOUTH_WEST:
       for (int x = -straightSight; x <= straightSight; ++x) {
         MapLocation senseLocation = loc.add(x, -straightSight);
         if (rc.canSense(senseLocation)) {
           rubbleTimes[senseLocation.x % MAP_MOD][senseLocation.y % MAP_MOD] = roundNum;
           mapRubble[senseLocation.x % MAP_MOD][senseLocation.y % MAP_MOD] =
               rc.senseRubble(senseLocation);
         }
       }
       break;
     default:
       break;
   }
   if (robotType == RobotType.ARCHON) mapParts[loc.x % MAP_MOD][loc.y % MAP_MOD] = 0;
 }