Esempio n. 1
0
  private void directStrategyOnePastr() throws GameActionException {
    boolean desperation = false;

    // Decided whether to trigger attack mode
    if (!attackModeTriggered) {
      // if the enemy has overextended himself building pastrs, attack!
      // I think even building two pastrs is an overextension that we can punish.
      if (numEnemyPastrs >= 2) {
        // We should only try to punish them if we have at least as many soldiers as they do
        // One issue is that we may be overestimating their strength because with some probability
        // they've built a noise tower, sacrificing a soldier and slowing their spawns more than
        // we would estimate. So fudge it by 1 soldier:
        if (numAlliedSoldiers + 1 >= maxEnemySoldiers) {
          // However, we need to make sure that at least one of these pastrs is outside their
          // HQ zone. There's no point in trying to punish them for building a bunch of pastrs
          // around their HQ; it doesn't help them and we can't kill them.
          if (theyHavePastrOutsideHQ()) {
            // If all these conditions are met, then punish them!
            attackModeTriggered = true;
          }
        }
      }

      // if the enemy is out-milking us, then we need to attack or we are going to lose
      if (theirMilk >= 0.4 * GameConstants.WIN_QTY && theirMilk > ourMilk) {
        // If they just have a single pastr next to their HQ, though, attacking them won't do much
        // good. Better to just hope we out-milk them
        if (theyHavePastrOutsideHQ()) {
          attackModeTriggered = true;
          desperation = true;
        }
      }
    }

    if (attackModeTriggered) {
      attackModeTarget = chooseEnemyPastrAttackTarget();

      // If we don't have a pastr, and we can't kill theirs, don't try to
      if (ourPastrs.length == 0
          && attackModeTarget != null
          && attackModeTarget.isAdjacentTo(theirHQ)) {
        attackModeTarget = null;
      }

      // if there's no pastr to attack, decide whether to camp their spawn or to defend/rebuid our
      // pastr:
      if (attackModeTarget == null) {
        // first, if our pastr has been destroyed we need to rebuild it instead of attacking.
        if (ourPastrs.length > 0) {
          // but if it's up, consider camping their spawn. Camping their spawn is only a good idea
          // if we are ahead on milk. Otherwise we should defend our pastr
          if (!desperation) {
            attackModeTarget = theirHQ;
          }
        }
      }
      MessageBoard.ATTACK_LOC.writeMapLocation(attackModeTarget);
    }
  }
Esempio n. 2
0
 private void directStrategyRush() throws GameActionException {
   attackModeTarget = chooseEnemyPastrAttackTarget();
   if (attackModeTarget == null) { // rally toward center if there are no enemy pastrs
     attackModeTarget = new MapLocation(rc.getMapWidth() / 2, rc.getMapHeight() / 2);
     while (rc.senseTerrainTile(attackModeTarget) == TerrainTile.VOID) {
       attackModeTarget = attackModeTarget.add(attackModeTarget.directionTo(ourHQ));
     }
   }
   MessageBoard.ATTACK_LOC.writeMapLocation(attackModeTarget);
 }
Esempio n. 3
0
  public void turn() throws GameActionException {
    if (rc.getConstructingRounds() > 0) return; // can't do anything while constructing

    if (Strategy.active == Strategy.HQ_PASTR) {
      if (spawnOrder == 1) {
        MapLocation pastrLoc = ourHQ.add(ourHQ.directionTo(here).rotateRight().rotateRight());
        constructNoiseTower(pastrLoc);
        return;
      }
      if (spawnOrder == 2) {
        rc.construct(RobotType.PASTR);
        return;
      }
    }

    updateEnemyData();
    MapLocation attackTarget = MessageBoard.ATTACK_LOC.readMapLocation();
    stance = chooseMicroStance(attackTarget);
    navEngage = stance == MicroStance.AGGRESSIVE ? Nav.Engage.YES : Nav.Engage.NO;

    // If there are enemies in attack range, fight!
    if (attackableEnemies.length > 0 && rc.isActive()) {
      fight();
      return;
    }

    // If we are in attack mode, move toward the attack target and engage.
    if (attackTarget != null) {
      if (rc.isActive()
          && attackTarget.distanceSquaredTo(theirHQ) <= 5
          && here.distanceSquaredTo(theirHQ) <= 35) {
        harrassTheirHQ();
        return;
      } else {
        Nav.goTo(attackTarget, Nav.Sneak.NO, navEngage);
        if (rc.isActive() && visibleEnemies.length > 0) fight();
        return;
      }
    }

    // See if we should build something
    maybeBuildSomething();

    // Build or defend a pastr
    buildOrDefendPastr();
  }