예제 #1
0
  private static int getNumberOfAlliedRobosAfterMe() throws GameActionException {
    int retval = 0;
    int myID = rc.getRobot().getID();

    Robot[] robos =
        rc.senseNearbyGameObjects(Robot.class, new MapLocation(0, 0), 1000000, rc.getTeam());

    for (Robot r : robos) {
      if (r.getID() > myID) {
        ++retval;
      }
    }

    return retval;
  }
예제 #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;
  }