Пример #1
0
 protected void sendSpam() throws GameActionException {
   Message m = new Message();
   m.ints = new int[1];
   m.locations = new MapLocation[1];
   m.locations[0] = new MapLocation(0, 0);
   m.strings = new String[1];
   m.strings[0] = "MQ_ATTACK";
   myRC.broadcast(m);
 }
Пример #2
0
  protected void sendEnemyLocation() throws GameActionException {
    enemyLocations = findEnemy();

    if (enemyLocations.length > 0) {
      Message m = new Message();
      m.ints = new int[1];
      m.ints[0] = MessageType.ENEMY_LOCATIONS.ordinal();
      m.locations = enemyLocations;
      // myRC.broadcast(m);
      sendMessage(m);
    } else {
      enemyDistance = Integer.MAX_VALUE;
    }
  }
Пример #3
0
  /** Calculates the order in which the archons were spawned. */
  public void senseArchonNumber() {
    Message[] messages = controller.getAllMessages();
    int min = 1;
    for (Message m : messages) {
      if (m.ints[0] >= min) {
        min = m.ints[0] + 1;
      }
    }

    archonNumber = min;

    Message m = new Message();
    m.ints = new int[] {min};
    try {
      controller.broadcast(m);
    } catch (Exception e) {
      System.out.println("----Caught Exception in senseArchonNumber.  Exception: " + e.toString());
    }
    System.out.println("Number: " + min);
  }
Пример #4
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);
   }
 }
Пример #5
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);
 }
Пример #6
0
 protected void sendMessage(Message m) throws GameActionException {
   m.strings = new String[2];
   m.strings[0] = "MQ_ATTACK";
   m.strings[1] = myRC.getTeam().toString();
   myRC.broadcast(m);
 }