Skip to content
Merged

sync #17

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 65 additions & 6 deletions RobotPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -280,12 +312,7 @@ public void run(){
Clock.yield();
Triple<Integer,Integer,Integer> 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);
Expand Down Expand Up @@ -645,6 +672,21 @@ public static Tuple<MapLocation, Double> 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
Expand Down Expand Up @@ -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;
}

}

Expand Down