Example #1
0
  public void turn() throws GameActionException {
    updateStrategicInfo();

    // First turn gets special treatment: spawn then do a bunch of computation
    // (which we devoutly hope will finished before the spawn timer is up
    // and before anyone attacks us).
    if (Clock.getRoundNum() == 0) {
      doFirstTurn();
      return;
    }

    if (rc.isActive()) {
      spawnSoldier();
    }

    attackEnemies();

    directStrategy();

    // Use spare bytecodes to do pathing computations
    MapLocation pathingDest;
    if (attackModeTarget != null) pathingDest = attackModeTarget;
    else if (computedBestPastrLocation != null) pathingDest = computedBestPastrLocation;
    else pathingDest = null;

    if (pathingDest != null) Bfs.work(pathingDest, rc, 9000);
  }
Example #2
0
  private static void turn() throws GameActionException {
    if (rc.getHealth() <= 6 * RobotType.SOLDIER.attackPower) {
      MessageBoard.PASTR_DISTRESS_SIGNAL.writeInt(Clock.getRoundNum());
    }

    // do speculative pathing calculations
    int bytecodeLimit = 9000;
    MapLocation[] enemyPastrs = rc.sensePastrLocations(them);
    for (int i = 0; i < enemyPastrs.length; i++) {
      if (Clock.getBytecodeNum() > bytecodeLimit) break;
      Bfs.work(enemyPastrs[i], Bfs.PRIORITY_LOW, bytecodeLimit);
    }
  }
Example #3
0
  protected static void init(RobotController theRC) throws GameActionException {
    rc = theRC;
    us = rc.getTeam();
    them = us.opponent();

    ourHQ = rc.senseHQLocation();
    theirHQ = rc.senseEnemyHQLocation();

    mapWidth = rc.getMapWidth();
    mapHeight = rc.getMapHeight();

    FastRandom.init();
    MessageBoard.init(theRC);
    Bfs.init(theRC);
  }
  // Computers
  private static void runOther() {
    int numTowers = -1;
    while (true) {
      threats.update();
      myLoc = rc.getLocation();

      // Move if we can and want to
      if (rc.isCoreReady() && myType.canMove()) {
        if (shouldRetreat()) doRetreatMove(); // Pull back if in range of the enemy guns
        else doAdvanceMove(); // Move towards our HQ
      }

      doTransfer();

      // Perform a background breadth first search to the enemy HQ
      if (myType == RobotType.COMPUTER && Clock.getBytecodesLeft() > 1000) {
        bfs.work(threats.enemyHQ, Bfs.PRIORITY_HIGH, 1000, numTowers != threats.enemyTowers.length);
      }
      numTowers = threats.enemyTowers.length;
      rc.yield();
    }
  }
  // Move towards enemy HQ if we can attack
  private static void doAdvanceMove() {
    try {
      if (myType == RobotType.COMMANDER
          && rc.hasLearnedSkill(CommanderSkillType.FLASH)
          && rc.getFlashCooldown() == 0) flashTowards(threats.enemyHQ, false);
    } catch (GameActionException e) {
      System.out.println("Flash exception");
      // e.printStackTrace();
    }

    if (rc.isCoreReady()) {
      Direction dir = null;

      if (myType.canAttack() || (myType == RobotType.LAUNCHER && Clock.getRoundNum() > 550)) {
        if (myType != RobotType.DRONE) dir = bfs.readResult(myLoc, threats.enemyHQ);
        if (dir == null) dir = myLoc.directionTo(threats.enemyHQ);
        rc.setIndicatorString(2, "Advancing " + dir);
      } else {
        dir = myLoc.directionTo(myHQ);
        rc.setIndicatorString(2, "HQ Defensive unit " + dir);
      }
      tryMove(dir, false);
    }
  }