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); } }
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); }