Buggy code:
public class Scout extends RobotPlayer { static ArrayList < Integer > seenUnits = new ArrayList < > ( ) ; static ArrayList < MapLocation > myArchonsLocation = new ArrayList < > ( ) ; static ArrayList < Integer > myArchonsID = new ArrayList < > ( ) ; static ArrayList < Integer > myArchonsLastSeen = new ArrayList < > ( ) ; static ArrayList < MapLocation > pastLocations = new ArrayList < > ( ) ; static Direction currentDir ; static Direction nextCorner ; static Boolean hasMoved ; static int [ ] [ ] danger ; static HashMap < Direction , MapLocation > corners = new HashMap < > ( ) ; static int stage ; static final int BROADCAST_DISTANCE = 12800 ; static final int MAX_TURNS = 30 ; static final int MAX_SEEN_UNITS = 5 ; private static void calculateDanger ( ) { } public static Direction safestDirection ( ) { } private static MapLocation baricentre ( Team a ) { } private static Direction randomDiagonalDirection ( ) { } private static void searchCorners ( ) throws GameActionException { } private static void calcLastCorner ( ) { } private static void returnToLeader ( ) { } private static Boolean canMove ( ) { } private static void addUnitToSeenList ( int id ) { } private static void addCorner ( int x , int y ) throws GameActionException { } private static void readSignals ( ) throws GameActionException { } private static void sendSignalsStage1 ( ) throws GameActionException { } public static double getPriority ( RobotInfo ri ) { } public static void sendSignalsStage2 ( ) throws GameActionException { } public static void playScout ( ) { try { targetLocation = escollirLider ( ) ; Scout . stage = 1 ; } catch ( Exception e ) { System . out . println ( e . getMessage ( ) ) ; e . printStackTrace ( ) ; } while ( true ) { try { if ( ( Scout . stage ) == 1 ) { rc . setIndicatorString ( 0 , "" ) ; nearbyEnemies = rc . senseNearbyRobots ( visionRange , enemyTeam ) ; nearbyZombies = rc . senseNearbyRobots ( visionRange , ZOMBIE ) ; nearbyNeutrals = rc . senseNearbyRobots ( visionRange , NEUTRAL ) ; nearbyFriends = rc . senseNearbyRobots ( visionRange , myTeam ) ; Scout . readSignals ( ) ; if ( rc . isCoreReady ( ) ) { Scout . hasMoved = false ; Scout . danger = new int [ 3 ] [ 3 ] ; if ( ( Scout . danger [ 1 ] [ 1 ] ) > 0 ) { Direction dir = Scout . safestDirection ( ) ; if ( dir != ( Direction . NONE ) ) { Scout . hasMoved = true ; rc . move ( dir ) ; rc . setIndicatorString ( 0 , "Hi<seq2seq4repair_space>havia<seq2seq4repair_space>perill<seq2seq4repair_space>i<seq2seq4repair_space>ha<seq2seq4repair_space>fugit" ) ; } } if ( Scout . canMove ( ) ) { if ( ( Scout . corners . size ( ) ) < 4 ) { Scout . searchCorners ( ) ; } else { Scout . returnToLeader ( ) ; rc . setIndicatorString ( 0 , "Ja<seq2seq4repair_space>ha<seq2seq4repair_space>trobat<seq2seq4repair_space>les<seq2seq4repair_space>4<seq2seq4repair_space>cantonades" ) ; } if ( ( Scout . currentDir ) != null ) { if ( Scout . canMove ( ) ) { rc . move ( Scout . currentDir ) ; Scout . pastLocations . add ( rc . getLocation ( ) ) ; if ( ( Scout . pastLocations . size ( ) ) > 5 ) Scout . pastLocations . remove ( 0 ) ; } } Scout . hasMoved = true ; } } rc . setIndicatorString ( 0 , ( "Es<seq2seq4repair_space>mou<seq2seq4repair_space>cap<seq2seq4repair_space>a<seq2seq4repair_space>la<seq2seq4repair_space>direccio<seq2seq4repair_space>" + ( Scout . nextCorner ) ) ) ; String s1 = "" ; String s2 = "" ; String s3 = "" ; String s4 = "" ; if ( Scout . corners . containsKey ( NORTH_EAST ) ) s1 = "NE" ; if ( Scout . corners . containsKey ( NORTH_WEST ) ) s2 = "NW" ; if ( Scout . corners . containsKey ( SOUTH_EAST ) ) s3 = "SE" ; if ( Scout . corners . containsKey ( SOUTH_WEST ) ) s4 = "SW" ; rc . setIndicatorString ( 1 , ( ( ( ( ( ( s1 + "<seq2seq4repair_space>" ) + s2 ) + "<seq2seq4repair_space>" ) + s3 ) + "<seq2seq4repair_space>" ) + s4 ) ) ; Scout . sendSignalsStage1 ( ) ; } else if ( ( Scout . stage ) == 2 ) { rc . setIndicatorString ( 0 , "" ) ; if ( rc . isCoreReady ( ) ) { <START_BUG> if ( ( rc . getLocation ( ) . distanceSquaredTo ( targetLocation ) ) > 18 ) { <END_BUG> Scout . returnToLeader ( ) ; rc . move ( Scout . currentDir ) ; } } if ( ( rc . getLocation ( ) . distanceSquaredTo ( targetLocation ) ) > 18 ) { Scout . sendSignalsStage2 ( ) ; } } Clock . yield ( ) ; } catch ( Exception e ) { System . out . println ( e . getMessage ( ) ) ; e . printStackTrace ( ) ; } } } }

Fix:
if ( ( rc . getLocation ( ) . distanceSquaredTo ( targetLocation ) ) > 25 ) {