// attempts to move toward a location
  // depending on the playstyle and unit type, it will avoid towers or other unit types
  public Boolean moveTo(Direction direction) throws GameActionException {

    if (!this.robot.robotController.canMove(direction)) return false;

    RobotType type = this.robot.type;
    Boolean moveAroundHQ =
        !this.robot.canAttackInHQRange(this.robot.unitController.enemyTowers().length);

    Boolean moveAroundTowers = !this.robot.canAttackInTowerRange();
    if (type == Missile.type()) moveAroundTowers = false;
    if (type == Launcher.type()) moveAroundTowers = true;

    Boolean moveAroundMilitary = false;
    if (UnitController.isUnitTypeMiner(type) && !this.robot.currentPlaystyle().shouldGoAllOut())
      moveAroundMilitary = true;
    else if (type == Drone.type()) moveAroundMilitary = true;
    else if (type == Launcher.type()) moveAroundMilitary = true;

    if (this.canMoveSafely(direction, moveAroundHQ, moveAroundTowers, moveAroundMilitary)) {

      this.robot.robotController.move(direction);
      return true;
    }
    return false;
  }
示例#2
0
  public void run() {

    super.run();

    try {

      if (this.robotController.isCoreReady()) {

        this.trySpawn(this.movementController.randomDirection(), Drone.type());
      }

    } catch (GameActionException exception) {
    }

    this.robotController.yield();
  }
  // @param turns    the amount of turns that the budget was saved up for
  // @param progress the progress that we are in the build order
  public void updateBudgetingForBuildOrderProgress(int turns, int oreMined, int progress)
      throws GameActionException {

    int remainingOre = oreMined;

    // check if we need to take some for the supply depots
    if (progress >= this.civicRatios.length - 1) {

      if (this.broadcaster.budgetForType(RobotType.SUPPLYDEPOT) < 250) {

        this.broadcaster.incrementBudget(RobotType.SUPPLYDEPOT, (int) (remainingOre * 0.1));
        remainingOre *= 0.9;
      }
    }

    // firstly check the beavers
    final int beavers = this.broadcaster.robotCountFor(Beaver.type());
    int beaverOreAllocation = 0;
    if (beavers == 0) {

      beaverOreAllocation = 100;
    }

    // miners
    final int minerFactories = this.broadcaster.robotCountFor(MinerFactory.type());
    int minerOreAllocation = 0;
    if (minerFactories > 0 && this.broadcaster.robotCountFor(Miner.type()) < 30) {

      minerOreAllocation = (60 / (20 / turns));
      if (this.broadcaster.budgetForType(Miner.type()) >= minerFactories * 60)
        minerOreAllocation = 0;
    }

    // launchers
    final int aerospaceLabs = this.broadcaster.robotCountFor(AerospaceLab.type());
    int launcherOreAllocation = aerospaceLabs * (400 / (100 / turns));
    if (this.broadcaster.budgetForType(Launcher.type()) >= aerospaceLabs * 400)
      launcherOreAllocation = 0;

    // drones
    int droneOreAllocation = 0;
    if (Clock.getRoundNum() > 600 && this.broadcaster.robotCountFor(Drone.type()) == 0) {

      droneOreAllocation = 8;
    }

    int total =
        beaverOreAllocation + minerOreAllocation + launcherOreAllocation + droneOreAllocation;
    double multiplier = (total > remainingOre) ? remainingOre / (float) total : 1.0;

    this.broadcaster.incrementBudget(Beaver.type(), (int) (beaverOreAllocation * multiplier));
    this.broadcaster.incrementBudget(Miner.type(), (int) (minerOreAllocation * multiplier));
    this.broadcaster.incrementBudget(Launcher.type(), (int) (launcherOreAllocation * multiplier));
    this.broadcaster.incrementBudget(Drone.type(), (int) (droneOreAllocation * multiplier));

    remainingOre -= total * multiplier;
    if (remainingOre > 40 && oreMined < 500 /* first turn */) {

      beaverOreAllocation = 10;
      this.broadcaster.incrementBudget(Beaver.type(), beaverOreAllocation);
      remainingOre -= beaverOreAllocation;
    }
    this.broadcaster.incrementCivicBudget(remainingOre);
  }