コード例 #1
0
  public static void run(RobotController theRC) {
    rc = theRC;

    // These don't change so get them once and use the local variable (performance)
    myType = rc.getType();
    myTeam = rc.getTeam();
    enemyTeam = myTeam.opponent();
    myHQ = rc.senseHQLocation();
    myLoc = rc.getLocation();
    senseRange = myType.sensorRadiusSquared;
    attackRange = myType.attackRadiusSquared;
    maxRounds = rc.getRoundLimit();

    if (myType == RobotType.MISSILE) runMissile();

    if (myType.canMove()) {
      bfs = new Bfs(rc); // We need to check the breadth first search results to move optimally
    }
    threats = new Threats(rc);

    if (myType == RobotType.HQ) runHQ();
    else if (myType == RobotType.TOWER) runTower();
    else if (myType.isBuilding) runBuilding();
    else if (myType.canBuild()) runBeaver();
    else if (myType.canMine()) runMiner(); // Includes Beavers
    else if (myType == RobotType.DRONE) runDrone();
    else if (myType.canAttack() || myType == RobotType.LAUNCHER) runCombat();
    else runOther();
  }
コード例 #2
0
  public static boolean canAttackInOneMove(RobotInfo[] nearbyZombies, MapLocation currentLocation) {
    int count = nearbyZombies.length;
    for (int i = 0; i < count; i++) {
      RobotType robotType = nearbyZombies[i].type;
      if (!robotType.canAttack()) {
        continue;
      }

      MapLocation enemyPosition = nearbyZombies[i].location;
      MapLocation nextPosition = enemyPosition.add(enemyPosition.directionTo(currentLocation));
      if (nextPosition.distanceSquaredTo(currentLocation) <= robotType.attackRadiusSquared) {
        return true;
      }
    }

    return false;
  }
コード例 #3
0
  public static boolean anyCanAttackConsideringTTMsTurrets(
      RobotInfo[] robots, MapLocation location) {
    for (RobotInfo robot : robots) {
      if (robot == null) {
        continue;
      }

      RobotType type = robot.type;
      if (type == RobotType.TTM) {
        if (robot.location.distanceSquaredTo(location) <= RobotType.TURRET.attackRadiusSquared) {
          return true;
        }
      } else {
        if (type.canAttack()
            && robot.location.distanceSquaredTo(location) <= type.attackRadiusSquared) {
          return true;
        }
      }
    }

    return false;
  }
コード例 #4
0
  // 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);
    }
  }
コード例 #5
0
 static boolean canDamage(RobotType r) {
   return r.canAttack() || r == RobotType.LAUNCHER || r == RobotType.MISSILE;
 }
コード例 #6
0
 private static boolean commanderLikes(RobotType t) {
   return (t == RobotType.MINER
       || t == RobotType.BEAVER
       || (t.isBuilding && t.canAttack() == false));
 }