diff --git a/RobotPlayer.java b/RobotPlayer.java index 67ebb27..2ab91b1 100644 --- a/RobotPlayer.java +++ b/RobotPlayer.java @@ -140,17 +140,17 @@ public void run() { */ private class Guard { - public MapLocation startLocation; + public MapLocation archonLocation; public int moveCount; public Guard() { - startLocation = rc.getLocation(); moveCount = 0; } public void run() { while(true){ try{ + archonLocation = RESOURCE_FUNCTIONS.scanFriendlyArchonLocation(); Signal[] signals = rc.emptySignalQueue(); if(signals.length > 0){ //if == 0, no signals, so not ready for(Signal s: signals){ @@ -172,13 +172,13 @@ public void run() { RobotInfo[] robots = rc.senseNearbyRobots(); boolean targetFound = false; for(RobotInfo robot:robots){ - if(robot.location.distanceSquaredTo(startLocation) < 25){ + if(robot.location.distanceSquaredTo(archonLocation) < 25){ targetFound = true; break; } } if(targetFound == false){ - RESOURCE_FUNCTIONS.BUG(startLocation); + RESOURCE_FUNCTIONS.BUG(archonLocation); } } if(rc.isWeaponReady()){ @@ -199,13 +199,13 @@ public void run() { if(rc.isWeaponReady()){ MapLocation target = null; for(RobotInfo robot: robots) { - if((robot.team == Team.ZOMBIE) && robot.location.distanceSquaredTo(startLocation) < 25) { + if((robot.team == Team.ZOMBIE) && robot.location.distanceSquaredTo(archonLocation) < 25) { target = robot.location; break; } } for(RobotInfo robot: robots) { - if((robot.team == opponentTeam) && robot.location.distanceSquaredTo(startLocation) < 25) { + if((robot.team == opponentTeam) && robot.location.distanceSquaredTo(archonLocation) < 25) { target = robot.location; break; } @@ -431,6 +431,23 @@ public static MapLocation scanArchonLocation() { } return null; } + + /** + * + * MapLocation scanFriendlyArchonLocation + * @return location of friendly archon + * + */ + public static MapLocation scanFriendlyArchonLocation() { + RobotInfo[] robots; + robots = rc.senseNearbyRobots(RobotType.SCOUT.sensorRadiusSquared, ourTeam); + for(int i = 0; i < robots.length; i++) { + if(robots[i].type == RobotType.ARCHON) { + return robots[i].location; + } + } + return null; + } /** * int dirToInt