// 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; }
public Boolean canMoveSafely( Direction direction, Boolean moveAroundHQ, Boolean moveAroundTowers, Boolean moveAroundUnits) throws GameActionException { if (direction == null) return false; RobotController rc = this.robot.robotController; Boolean canMove = rc.canMove(direction); if (!canMove) return false; // run some initial checks MapLocation towerLocation = this.robot.locationController.enemyTowerInRange(); if (towerLocation != null) moveAroundTowers = false; // start checking if we can move MapLocation currentLocation = this.robot.locationController.currentLocation(); MapLocation moveLocation = currentLocation.add(direction); if (moveAroundHQ) { MapLocation[] towers = this.robot.unitController.enemyTowers(); if (moveLocation.distanceSquaredTo(this.robot.locationController.enemyHQLocation()) <= HQ.enemyAttackRadiusSquared(towers.length)) return false; } if (moveAroundTowers) { MapLocation[] towers = this.robot.unitController.enemyTowers(); for (MapLocation tower : towers) { if (moveLocation.distanceSquaredTo(tower) <= Tower.type().attackRadiusSquared) return false; } } if (moveAroundUnits) { double buffer = 0; if (this.robot.type == Launcher.type()) buffer = 10; RobotInfo[] enemies = this.robot.unitController.nearbyEnemies(); for (RobotInfo enemy : enemies) { this.robot.broadcaster.evaluateSeenLaunchersWithType(enemy.type); if (!UnitController.isUnitTypeDangerous(enemy.type)) continue; if (moveLocation.distanceSquaredTo(enemy.location) <= enemy.type.attackRadiusSquared + buffer) return false; } } return true; }
public Boolean canMobilizeForClockNumber(int clockNumber) throws GameActionException { int totalLaunchers = this.broadcaster.robotCountFor(Launcher.type()); if (totalLaunchers > 8) { return true; } else { if ((clockNumber > 1400 && clockNumber < 2000)) { return true; } } return false; }
public Boolean canMobilizeForClockNumber(int clockNumber, int roundLimit) throws GameActionException { int totalLaunchers = this.broadcaster.robotCountFor(Launcher.type()); if (this.broadcaster.hasSeenLaunchers()) { if (totalLaunchers > 6) return true; } else { if (clockNumber > roundLimit - 300) { return true; } else { if (totalLaunchers > 6) return true; } } return false; }
// @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); }