Example #1
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);
  }
Example #2
0
  public void placeTower() {
    idealTowerSpawnLocations = null;
    turnsWaitedForTowerSpawnLocationMessage = 0;
    towerSpawnFromLocation = null;
    towerSpawnLocation = null;
    turnsWaitedForMove = 0;

    ArrayList<MapLocation> towers; // //sensing.senseAlliedTeleporters();
    int towerID = BroadcastMessage.everyone;
    MapLocation location;
    Robot robot;

    towers = sensing.senseAlliedTowerLocations();
    if (towers.size() > 0) {
      // no teles in range, but there are other towers.  they should be talking to the tele and
      // should know the status of where to build
      try {
        location = navigation.findClosest(towers);
        if (controller.canSenseSquare(location) && location != null) {
          robot = controller.senseGroundRobotAtLocation(location);
          if (robot != null) towerID = robot.getID();
          else pa("cannot sense robot at " + location);
        }
        messaging.sendTowerBuildLocationRequest(towerID);
        setGoal(Goal.askingForTowerLocation);
        return;
      } catch (Exception e) {
        pa("----Caught exception in place tower. " + e.toString());
      }
    }

    // no towers in range, lets just ask everyone
    messaging.sendTowerBuildLocationRequest(BroadcastMessage.everyone);
    setGoal(Goal.askingForTowerLocation);
    return;
  }