예제 #1
0
 private static void broadcastingAttack(RobotController rc, RobotInfo enemy)
     throws GameActionException {
   if (enemy.health <= RobotType.SOLDIER.attackPower) {
     if (enemy.type == RobotType.ZOMBIEDEN) {
       rc.attackLocation(enemy.location);
       Message.sendBasicGivenRange(rc, Message.FULL_MAP_RANGE);
       denLocations.remove(enemy.location);
       nearestDenLocation = denLocations.getClosest(myLoc);
     } else {
       rc.attackLocation(enemy.location);
     }
   } else {
     rc.attackLocation(enemy.location);
   }
 }
예제 #2
0
 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]);
   }
 }
예제 #3
0
 // reads the message signals and sets the nearestTurretLocation and currentDestination static
 // variables
 public static void readMessages(RobotController rc) {
   List<Message> messages = Message.readMessageSignals(rc);
   // we want to loop through each message and get the ones that are relevant to the soldier
   distressedArchonTurns++;
   for (Message m : messages) {
     // if the message is a turret, try to get the nearest turret location
     if (m.type == Message.TURRET) {
       turretLocations.add(m.location);
       if (nearestTurretLocation == null) {
         nearestTurretLocation = m.location;
       } else if (myLoc.distanceSquaredTo(m.location)
           < myLoc.distanceSquaredTo(nearestTurretLocation)) {
         nearestTurretLocation = m.location;
       }
     } else
     // if the message is to remove a turret, and if it's our nearestTurret, remove it
     if (m.type == Message.TURRETKILLED) {
       turretLocations.remove(m.location);
       // Compute the new closest turret
       if (m.location.equals(nearestTurretLocation)) {
         nearestTurretLocation = turretLocations.getClosest(myLoc);
       }
     } else
     // if the message is an enemy, get the closet one
     if (m.type == Message.ENEMY) {
       if (nearestEnemyLocation == null) {
         nearestEnemyLocation = m.location;
       } else if (myLoc.distanceSquaredTo(m.location)
           < myLoc.distanceSquaredTo(nearestEnemyLocation)) {
         nearestEnemyLocation = m.location;
       }
     } else
     // if the message is a den, get the closest one
     if (m.type == Message.ZOMBIEDEN) {
       denLocations.add(m.location);
       if (nearestDenLocation == null) {
         nearestDenLocation = m.location;
       } else if (myLoc.distanceSquaredTo(m.location)
           < myLoc.distanceSquaredTo(nearestDenLocation)) {
         nearestDenLocation = m.location;
       }
     } else
     // if zombie killed message, then recompute the nearest den and remove den location.
     if (m.type == Message.ZOMBIEDENKILLED) {
       denLocations.remove(m.location);
       if (m.location.equals(nearestDenLocation)) {
         nearestDenLocation = denLocations.getClosest(myLoc);
       }
     } else
     // if the message is an archon location, store the nearest current archon location
     if (m.type == Message.ARCHONLOC) {
       if (newArchonLoc == null) {
         newArchonLoc = m.location;
       } else if (myLoc.distanceSquaredTo(m.location) < myLoc.distanceSquaredTo(newArchonLoc)) {
         newArchonLoc = m.location;
       }
     } else
     // if we get a rush signal, we want to rush towards the nearest turret
     if (m.type == Message.RUSH) {
       MapLocation closestTurret = turretLocations.getClosest(myLoc);
       if (closestTurret != null) {
         if (myLoc.distanceSquaredTo(closestTurret) <= 400) {
           rush = true;
           rushLocation = closestTurret;
         }
       }
     } else
     // if we get an archon in distressed signal, needs to take priority
     if (m.type == Message.ARCHONINDANGER) {
       distressedArchonTurns = 0;
       if (nearestDistressedArchon == null) {
         nearestDistressedArchon = m.location;
       } else if (myLoc.distanceSquaredTo(m.location)
           < myLoc.distanceSquaredTo(nearestDistressedArchon)) {
         nearestDistressedArchon = m.location;
       }
     } else
     // if we get a basic message, then remove the closest den location
     if (m.type == Message.BASIC) {
       MapLocation reference = m.signal.getLocation();
       MapLocation closestDen = denLocations.getClosest(reference);
       denLocations.remove(closestDen);
       nearestDenLocation = denLocations.getClosest(myLoc);
     }
   }
   // if we actually have a destination, set it to currentDestination
   setCurrentDestination(rc);
 }