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
13 changes: 9 additions & 4 deletions RobotPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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;
Expand Down