Example #1
0
  private void updateStrategicInfo() throws GameActionException {
    theirPastrs = rc.sensePastrLocations(them);
    numEnemyPastrs = theirPastrs.length;
    ourPastrs = rc.sensePastrLocations(us);
    numAlliedPastrs = ourPastrs.length;

    int numKillsLastTurn = MessageBoard.ROUND_KILL_COUNT.readInt();
    MessageBoard.ROUND_KILL_COUNT.writeInt(0);
    maxEnemySpawns -= numKillsLastTurn;

    virtualSpawnCountdown--;
    if (virtualSpawnCountdown <= 0) {
      maxEnemySpawns++;
      int maxEnemyPopCount = maxEnemySpawns + numEnemyPastrs;
      virtualSpawnCountdown =
          (int)
              Math.round(
                  GameConstants.HQ_SPAWN_DELAY_CONSTANT_1
                      + Math.pow(maxEnemyPopCount - 1, GameConstants.HQ_SPAWN_DELAY_CONSTANT_2));
    }
    maxEnemySoldiers = maxEnemySpawns - numEnemyPastrs;

    numAlliedSoldiers = 0;
    Robot[] allAlliedRobots = rc.senseNearbyGameObjects(Robot.class, 999999, us);
    allAllies = new RobotInfo[allAlliedRobots.length];
    for (int i = allAlliedRobots.length; i-- > 0; ) {
      RobotInfo info = rc.senseRobotInfo(allAlliedRobots[i]);
      allAllies[i] = info;
      if (info.type == RobotType.SOLDIER) numAlliedSoldiers++;
    }

    ourMilk = rc.senseTeamMilkQuantity(us);
    theirMilk = rc.senseTeamMilkQuantity(them);
  }
Example #2
0
 private void attackAndRecord(RobotInfo enemyInfo) throws GameActionException {
   if (enemyInfo == null) return; // should never happen, but just to be sure
   rc.attackSquare(enemyInfo.location);
   if (enemyInfo.health <= RobotType.SOLDIER.attackPower)
     MessageBoard.ROUND_KILL_COUNT.incrementInt();
 }