Skip to content
Merged
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
49 changes: 49 additions & 0 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 @@ -981,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