diff --git a/RobotPlayer.java b/RobotPlayer.java index f59d410..b816a22 100644 --- a/RobotPlayer.java +++ b/RobotPlayer.java @@ -61,6 +61,38 @@ else if(selftype == RobotType.SOLDIER) { } } + /** + * + * Class Turret + * + * The class outlining our turret bots + * + */ + private class Turret{ + + MapLocation enemyLocation; + + public Turret(){ + + } + + public void run(){ + while(true){ + try{ + + if(rc.isWeaponReady()){ + enemyLocation = RESOURCE_FUNCTIONS.locateStrongestEnemy(); + if(rc.canAttackLocation(enemyLocation)){ + rc.attackLocation(enemyLocation); + } + } + } + catch (Exception e) { + e.printStackTrace(); + } + } + } + } /** * Class Soldier * @@ -280,12 +312,7 @@ public void run(){ Clock.yield(); Triple scoutType = getScoutInitType(); //Check if near zombie round - int roundNum = rc.getRoundNum(); - boolean isCloseToZombieRound = false; - for (int i = 0; i < zombieRounds.length && !isCloseToZombieRound; i++) { - isCloseToZombieRound = (Math.abs(roundNum - zombieRounds[i]) < 10); - } - if (mostRecentEnemyArchonLocations.size() != 0 && isCloseToZombieRound) { + if (mostRecentEnemyArchonLocations.size() != 0 && RESOURCE_FUNCTIONS.isCloseToZombieSpawnRound()) { scoutType = getScoutHerdingType(); } FancyMessage.sendMessage(0,scoutType.first | scoutType.second,scoutType.third,3); @@ -645,6 +672,21 @@ public static Tuple findLargestPileOfParts() { return locationAndSize; } + + /** + * isCloseToZombieSpawnRound + * @returns whether or not the current round is close enough to a zombie spawn round + * to make a scout be a zombie herder + */ + public static boolean isCloseToZombieSpawnRound() { + int roundNum = rc.getRoundNum(); + boolean isCloseToZombieRound = false; + for (int i = 0; i < zombieRounds.length && !isCloseToZombieRound; i++) { + int diff = zombieRounds[i] - roundNum; + isCloseToZombieRound = (diff < 50 && diff > -5); + } + return isCloseToZombieRound; + } /** * boolean moveAsFarAwayAsPossibleFrom @@ -971,6 +1013,23 @@ public static MapLocation locateWeakestEnemy(){ } return null; } + public static MapLocation locateStrongestEnemy(){ + RobotInfo[] enemies = rc.senseHostileRobots(rc.getLocation(), rc.getType().sensorRadiusSquared); + if(enemies != null){ + double max = 0; + RobotInfo strongest = null; + for(RobotInfo robot: enemies){ + if(robot.health > max && robot.location.distanceSquaredTo(rc.getLocation()) >= GameConstants.TURRET_MINIMUM_RANGE){ + max = robot.health; + strongest = robot; + } + } + if(strongest != null){ + return strongest.location; + } + } + return null; + } }