diff --git a/RobotPlayer.java b/RobotPlayer.java index d286886..19d0f6e 100644 --- a/RobotPlayer.java +++ b/RobotPlayer.java @@ -762,6 +762,9 @@ public static boolean BUG(MapLocation target) throws GameActionException{ } public static void escapeEnemy(RobotController rc){ MapLocation enemyLocation = locateEnemy(rc); + if(enemyLocation == null){ + return; + } Direction moveDirection = calculateEscapeDirection(rc, enemyLocation); if(rc.canMove(moveDirection)){ try{ @@ -776,11 +779,13 @@ public static void escapeEnemy(RobotController rc){ } public static MapLocation locateEnemy(RobotController rc){ - RobotInfo[] sensedRobots = rc.senseNearbyRobots(); + RobotInfo[] sensedRobots = rc.senseHostileRobots(rc.getLocation(),rc.getType().sensorRadiusSquared); MapLocation closest = null; - for(RobotInfo robot: sensedRobots){ - if(robot.team == opponentTeam || robot.team == Team.ZOMBIE){ - return robot.location; + if(sensedRobots != null){ + for(RobotInfo robot: sensedRobots){ + if(robot.team == opponentTeam || robot.team == Team.ZOMBIE){ + return robot.location; + } } } return null;