From 069f39a44f17c8f265991311d97a95d8f32ff749 Mon Sep 17 00:00:00 2001 From: androidmage Date: Sun, 10 Jan 2016 13:59:36 -0500 Subject: [PATCH] Got rid of nullpointerexception for archon --- RobotPlayer.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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;